Before ending a user's session, make sure that you have the following information :
  1. OpenID Provider Metadata (autodiscovery URL) : Your admin can provide you with the URL which lives in https://${realm.url}/oauth/${realm.name}/.well-known/openid-configuration
  2. An id_token for the logged in user.
The end_session flow only works for OpenID Connect flows (which generate an id_token)
Before triggering a logout request, make sure to revoke all the access_tokens which have been received by your application

End Session Request

To initiate a logout request, you must redirect the user browser to the OpenID Provider end_session_endpoint
The parameters available are :
ParameterRequiredDescription
id_token_hintYesAn id_token previously generated to your application which will allow the Authorization Server (Realm) to end the correct session.
post_logout_redirect_uriYesOne of the URLs registered by the client. It must be an exact match. If you use a post_logout_redirect_uri which has not been registered, an error will be returned
stateNoA string that your app creates which the OpenID Provider will return in the response. It's highly recommended to use a state parameter to protect your application against CSRF attacks
Example request :
https://openid.provider/end_session?
id_token_hint=AN_ID_TOKEN&
post_logout_redirect_uri=https://your.awesome.app/&
state=STATE_OF_YOUR_APP

Single Logout

When a Realm receives a logout request, it'll trigger a Single Logout on all applications that a user has logged into in the current community. The user will therefore logout from all Realms within the same community.

Configuring Single Logout

If your application must participate in Single Logout and receive the information that a user decided to logout from another application, it must provide the frontchannel_logout_uri during registration
The Realm will trigger the following page load on an iframe :
https://your.awesome.app/slo?
sid=AN_SID_RECEIVED_PREVIOUSLY
ParameterRequiredDescription
sidYesA session id (sid) which was previously provided as a claim in the id_token which will allows your application to end the correct session.
At this time, your application will have to revoke all access_tokens for this session and clean any cookies or session data.
Make sure to whitelist the Community domain on your CSP and X-FRAME-OPTIONS for the Single Logout page

End Session Response

The Authorization Server will logout the user and will redirect the browser back to the specified _post_logout_redirect_uri.
https://your.awesome.app/?
state=STATE_OF_YOUR_APP