DJKnaeckebrot
DJKnaeckebrot
Explore posts from servers
DDokploy
Created by DJKnaeckebrot on 11/10/2024 in #help
Use self hosted Gitlab
Oh okay thanks for letting me know 🙂 I searched trough the discord but not yet through Github 😄
5 replies
DDokploy
Created by DJKnaeckebrot on 11/10/2024 in #help
Use self hosted Gitlab
Yeah it's, I was just wondering if I can also you the Gitlab integration with it or if it only works with gitlab.com
5 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
I just saw I might can add another check in the else if for the url not being null tho
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
Hey @Dave - Kinde sorry for the ping. I have made some changes to the SDK so it adds the /api/auth/postlogout functionallity. I was just wondering if this looks good to you guys before I open the PR
import RouterClient from '../routerClients/RouterClient';
import {config} from '../config/index';

/**
*
* @param {RouterClient} routerClient
*/

export const postlogout = async (routerClient) => {
const postLogoutRedirectURL = routerClient.sessionManager.getSessionItem(
'post_logout_redirect_url'
);

let redirectURL;

if (config.redirectURL + postLogoutRedirectURL === config.postLogoutRedirectURL || postLogoutRedirectURL === null) {
redirectURL = config.postLogoutRedirectURL;
} else if (!postLogoutRedirectURL.startsWith("http") && !postLogoutRedirectURL.startsWith("https")) {
redirectURL = config.redirectURL + postLogoutRedirectURL;
}

await routerClient.sessionManager.removeSessionItem('post_logout_redirect_url');

routerClient.redirect(redirectURL);
};
import RouterClient from '../routerClients/RouterClient';
import {config} from '../config/index';

/**
*
* @param {RouterClient} routerClient
*/

export const postlogout = async (routerClient) => {
const postLogoutRedirectURL = routerClient.sessionManager.getSessionItem(
'post_logout_redirect_url'
);

let redirectURL;

if (config.redirectURL + postLogoutRedirectURL === config.postLogoutRedirectURL || postLogoutRedirectURL === null) {
redirectURL = config.postLogoutRedirectURL;
} else if (!postLogoutRedirectURL.startsWith("http") && !postLogoutRedirectURL.startsWith("https")) {
redirectURL = config.redirectURL + postLogoutRedirectURL;
}

await routerClient.sessionManager.removeSessionItem('post_logout_redirect_url');

routerClient.redirect(redirectURL);
};
I added a remove of the sessionItem before the redirect cause otherwise if you only use logout it will keep using that cookie (atleast for me) 😄
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
I like the 3. solution as it seems to be the best of both worlds 🙂
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
thanks for your help to both of you!
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
+1
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
I had to add the KINDE_SITE_URL as I use a reverse proxy and the provided code was putting localhost:4001 instead of my domain 😄 Otherwise its working now! For reference if anyone ever needs it I'll leave the code for the /api/logout/ route
import { cookies } from "next/headers";
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest) {
const cookieJar = cookies();

// @ts-ignore
let path = cookieJar.get("post_logout_redirect_url").value;

// Get the domain from environment variable
const siteURL = process.env.KINDE_SITE_URL;

// Ensure siteURL is not empty and path is not an absolute URL
if (siteURL && !path.startsWith("http")) {
// Prepend domain to the path
path = siteURL + path;
}

return NextResponse.redirect(new URL(path, request.url));
}
import { cookies } from "next/headers";
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest) {
const cookieJar = cookies();

// @ts-ignore
let path = cookieJar.get("post_logout_redirect_url").value;

// Get the domain from environment variable
const siteURL = process.env.KINDE_SITE_URL;

// Ensure siteURL is not empty and path is not an absolute URL
if (siteURL && !path.startsWith("http")) {
// Prepend domain to the path
path = siteURL + path;
}

return NextResponse.redirect(new URL(path, request.url));
}
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
Thanks for this detailed response! I'll try to get this implemented and will let you know! Eitherway I am just wondering if this SDK still should be able to do this without making this "workaround" with the custom logout page? If so I might can try to dig deeper on why it wont pass/use the param 🙂
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
Yeah i set those urls 😄 Was the first thing I checked haha as I initially was landing on the kinde default page so I added all pages and even with the searchParams in the URL 😄
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
Little Update: I have checked the typescipt SDK as this gets referenced: types.d.ts:
..
register: (
sessionManager: SessionManager,
options?: RegisterURLOptions
) => Promise<URL>;
getUser: (sessionManager: SessionManager) => Promise<UserType>;
logout: (sessionManager: SessionManager) => Promise<URL>;
login: (
sessionManager: SessionManager,
options?: LoginURLOptions
) => Promise<URL>;
..
..
register: (
sessionManager: SessionManager,
options?: RegisterURLOptions
) => Promise<URL>;
getUser: (sessionManager: SessionManager) => Promise<UserType>;
logout: (sessionManager: SessionManager) => Promise<URL>;
login: (
sessionManager: SessionManager,
options?: LoginURLOptions
) => Promise<URL>;
..
Seems as if for the types the options are missing. Checking the src/routerClients/AppRouterClient.js it references the typescript SDK with the this.kindeClient call:
import {createKindeServerClient} from '@kinde-oss/kinde-typescript-sdk';

..
this.kindeClient = createKindeServerClient(
config.grantType,
config.clientOptions
);
import {createKindeServerClient} from '@kinde-oss/kinde-typescript-sdk';

..
this.kindeClient = createKindeServerClient(
config.grantType,
config.clientOptions
);
While the src/handlers/logout.js call sets up the authURL by using:
const authUrl = await routerClient.kindeClient.logout(
routerClient.sessionManager,
{
authUrlParams: Object.fromEntries(routerClient.searchParams),
}
);
const authUrl = await routerClient.kindeClient.logout(
routerClient.sessionManager,
{
authUrlParams: Object.fromEntries(routerClient.searchParams),
}
);
Console logging the authUrl leads to : https://identity.teamsynix.org/logout?redirect=http://localhost:3000/login while authUrlParams: Object.fromEntries(routerClient.searchParams) returns : {"post_logout_redirect_url":"/login?type=bewerben"} Tbh I dont rly know if this error is within the typescript SDK or the NextJS SDK..
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
hahaha lol!
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
this basically always uses my set default logout url and not the one provided in the URL if I understood it right
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
No description
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
oh yeah, but I am not too sure if you get back to the callback on logout
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
No description
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
yeah guess I'll need to wait for one of the kinde guys to have a look. I'lL might do some more digging but I am kinda stuck rn 😄 Thanks for your help so far tho, much appretiated!
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
yep same for me 😦
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
No unfortunately not. Im currently following a "hint" that in the SessionManger it only has the post login url as cookie but not the post logout url https://github.com/kinde-oss/kinde-auth-nextjs/blob/059547d6b6eb88b808aab04c653a380ecdb30ab3/src/session/sessionManager.js#L23 I will check if adding the post logout url will change anything otherwise the kinde guys need to have a view
66 replies
KKinde
Created by DJKnaeckebrot on 2/26/2024 in #💻┃support
Post Logout Redirect Parameter
I can see that it adds the parameter to the url but i haven’t found out where this logic is getting processed so where the actual redirect happens. For me it seems that the issue might be there
66 replies