Skip to content

Redirect after logout with oAuth2 OpenID protocol #1012

Open
@Dashboard-Community-Center

Description

First of all, thank you for your work!
I had an issue with the MS OpenID protocol due to a wrong query parameters in my logout scheme. By default, auth-next redirect the user to the ADFS home page with the client_id and the logout_uri parameters.
Using it, I was successfully logged out but I was not redirected to the home page of my application defined in the redirect.logout or logoutRedirectUri properties.
In order to be properly redirected, I had to forked the library and modifed the distribution files (runtime.js and runtime.mjs) as follow

logout() {
  if (this.options.endpoints.logout) {
    let myToken = this.token.get()
    if (myToken.includes('Bearer')) {
      myToken = myToken.substring(7);
    }
    const opts = {
      post_logout_redirect_uri: this.logoutRedirectURI,
      id_token_hint: myToken
    };
    const url = this.options.endpoints.logout + "?" + encodeQuery(opts);
    window.location.replace(url);
  }
  return this.$auth.reset();
}

instead of

logout() {
  if (this.options.endpoints.logout) {
    const opts = {
      client_id: this.options.clientId + '',
      logout_uri: this.logoutRedirectURI
    }
    const url = this.options.endpoints.logout + '?' + encodeQuery(opts)
    window.location.replace(url)
  }
  return this.$auth.reset()
}

Clearly not the best approach but we had to deploy it asap. Please let me know if this is of interest to match the protocol described below. It is working on my side but I would rather bring it in the scope of your project.

https://docs.microsoft.com/en-us/answers/questions/60633/azure-ad-openid-connect-post-logout-redirect-uri-w.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions