Skip to content

post_logout_redirect_uri during logout and last visited url #1487

Closed
@lomboboo

Description

@lomboboo

Issue and Steps to Reproduce

Trying to evaluate this package for our needs instead of oidc-client-ts. Your package has a very clever solution to the refresh token flow problems, so kudos to all involved!

I mostly got everything working except during logout, by default post_logout_redirect_uri is set to the current path from the window location. In my understand it should be a part of the ODIC configuration as a required property.

Instead, when logout() called is sets post_logout_redirect_uri to the current path and fails validation with IdentityServer ClientPostLogoutRedirectUris table ending up on the Logout page in IdentityServer with no redirection back.

Since there is no post_logout_redirect_uri in the ODIC configuration, I am calling logout(window.location.origin) so that post_logout_redirect_uri matches with my IDS4 configuration, but now I am not sure how to redirect user to the page he was logged out from. I image it would be something like oidc-client-ts does, setting state with lastUrl or smth and storing it somewhere in localstorage. Then retrieve it in some event or creating special route for post logout url - not sure, but I can't find any examples of how to do this correctly or maybe it's already implemented in some way and I couldn't find it.

My goal here is during any logout user should be redirected back to the page he was logged out from after re-login.

Versions

oidc-client - Latest
IdentityServer4 - 3.1.0

const configuration = {
    client_id: ClientConfig.config.clientId,
    redirect_uri: `${ClientConfig.config.hostBaseUrl}/callback`,
    silent_redirect_uri: `${ClientConfig.config.hostBaseUrl}/silent-callback`,
    scope: `openid profile ${ClientConfig.config.clientId} offline_access`,
    authority: ClientConfig.config.idpServerUrl,
    service_worker_relative_url: '/OidcServiceWorker.js',
    service_worker_only: false,
  };
  ...
  
  const onClickLogout = () => {
    ...
    await logout(window.location.origin);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions