We are implementing a logout action within our application which first destroys the user’s session within our application, then redirects the user to the auth0 tenant domain’s logout endpoint. The name for this I believe is a SP initiated logout. Specifically SP (our app) to Idp (Auth0), in this case is our application logout redirects to the Auth0 logout endpoint.
Expected behavior: After redirecting the user to the auth0 logout endpoint, the auth0 session gets cleared for that user. Then when the user initiates a new login from our application, they will have to reauthenticate on auth0.
Observed behavior: After redirecting the user to the auth0 logout endpoint, the auth0 session remains. Initiating a login on auth0 from our application authenticates with the pre-existing session on auth0, and the previously logged in user is authenticated on our application without seeing the universal login page.
What I’ve tried:
Set the sso_disabled: false
in the auth0 client web application’s configuration following this guide:
First set the auth0 tenant Settings > Advanced > Session Expiration > Session Policy: Persistent
Approach 1:
Using https://auth0.com/docs/api/authentication/logout/auth-0-logout (the /v2/logout endpoint)
Then in our application, we’veimplement the following.
- The user clicks a ‘/logout’ link in our application this calls destroy session in our app.
- The app redirects the user to TENANT_DOMAIN/v2/logout
Testing this:
- log in in a new browser
- The user is authenticated, logged into our app
- Click the logout link in our app
- Redirect is successful to TENANT_DOMAIN/v2/logout We see a blank screen with the text ‘OK’
- Go back to our app, the user is logged out in our app.
- Check the logs in the Auth0 tenant and see a “Successful Logout” log.
- Click the login link on our app
- The previous user is silently authenticated on auth0 and redirected to our app as the user from step 1, they are not shown the universal login screen
Approach 2:
Using https://auth0.com/docs/api/authentication/logout/oidc-logout (the /oidc/logout endpoint)
I tried a very similar approach, and I did read the docs specific to oidc so I tried a few additional parameters.
Included the id_token_hint, a client_id which matches the ‘aud’ in the id_token.
The test results
- log in in a new browser
- The user is authenticated, logged into our app
- Click the logout link in our app
- Redirect is successful to TENANT_DOMAIN/v2/logout We see a styled logout screen with a logo and green check
- Go back to our app, the user is logged out in our app.
- Check the logs in the Auth0 tenant and see a “Successful Logout” logout screen.
- Click the login on our app
- The previous user is silently authenticated on auth0 and redirected to our app as the user from step 1, they are not shown the universal login screen
More info for debugging:
The Successful logout logs in the 2 approaches for Success Logout were sparse with information, the values for user_id, user_name, connection_id were empty strings. I think they should have the values set in the logs, and the session id/sid is missing. So that is suspicious.
When sso_disabled: true
in the auth0 client web application’s configuration, the user is always prompted to login on every authentication so the problems described dont occur, however I believe we want the auth0 session to persist unless we specifically redirect the user to any of these logout endpoints.
Any information or help on this issue is appreciated.