Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normal signout process with IdentityServer4 (OIDC) #1860

Open
slucas-elsa opened this issue Dec 4, 2023 · 0 comments
Open

Normal signout process with IdentityServer4 (OIDC) #1860

slucas-elsa opened this issue Dec 4, 2023 · 0 comments
Labels

Comments

@slucas-elsa
Copy link

Hi,

I've added the signout process on a Nuxt3 app last week and even if it works, I'm still not sure if I did it the right way or not.

Note that I did not code the login part and that I read thoroughly this discussion before starting to dev nextauthjs/next-auth#3938

First I modified my server/api/auth/[...].ts to modify the callbacks session and jwt to make the IdToken available.

Then to logout it's quite easy :

        const { data: authData } = useAuth();
        const idToken = (authData.value as any)?.idToken;
        const redirectUrl = runtimeConfig.public.AUTH_ORIGIN;
        const endSessionUrl = `${runtimeConfig.public.AUTH_ISSUER_IDSERVER}/connect/endsession?id_token_hint=${idToken}&post_logout_redirect_uri=${redirectUrl}`;

        await signOut({ redirect: false });

        window.location.href = endSessionUrl;

So I call signOut first with no callback and end with a redirect to the endsession which will redirect me to my signin page if all goes well.

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant