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

How to properly signout from IDP server? #1245

Open
dszy579 opened this issue May 15, 2024 · 2 comments
Open

How to properly signout from IDP server? #1245

dszy579 opened this issue May 15, 2024 · 2 comments
Labels
question Further information is requested

Comments

@dszy579
Copy link

dszy579 commented May 15, 2024

I've configured a single logout with auth.signoutRedirect() with a logout button in the UI.

Here is my configuration:

auth config

export const oidcConfig: AuthProviderProps = {
  client_id: '...',
  authority: '...',
  redirect_uri: '...',
  metadata: {
    issuer: '...',
    authorization_endpoint: '...',
    token_endpoint: '...'
    end_session_endpoint: '/oauth2/logout',
    frontchannel_logout_supported: true,
    frontchannel_logout_session_supported: true,
  },
  automaticSilentRenew: false,
  monitorSession: true,
  post_logout_redirect_uri: '...',
  onSigninCallback: () => {
    window.history.replaceState({}, document.title, window.location.pathname)
  },
}

logout implementation:

  const onLogout = async () => {
    await auth.signoutRedirect()
    window.sessionStorage.clear()
  }

When the user clicks the logout button, the web app will trigger auth.signoutRedirect() and clear the session storage related to oidc:user. and will be redirected to the IDP logout page to show that the user has successfully signed out.

But, when the user tried to access the web again it seemed like it wasn't completely logged out. I noticed that the web still got the authorization code params automatically on the browser which then makes the user stay logged in.

Any idea why this happened? how to properly logoff the user completely from the app and IDP?

@ValGab
Copy link

ValGab commented May 15, 2024

Hello, did you use auth.removeUser() with auth.signoutRedirect() ?

Here is my implementation

onClick={() => {
                auth.removeUser();
                auth.signoutRedirect({ id_token_hint: auth.user?.id_token });
              }}

@dszy579
Copy link
Author

dszy579 commented May 16, 2024

@ValGab thank you for your response, I've updated the issue to add more context to my logout implementation and it seems I made a mistake when calling the clear session method.

I've tried your implementation, but still no luck.

@pamapa pamapa added the question Further information is requested label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants