RP-initiated logout
When Ava wants the photo service signed out too, the collage app cannot end that session itself. It ends its own session, then sends her browser to the provider's end session endpoint with a hint about which session it means and a registered address to come back to.
Asking the provider to sign Ava out
After the trouble at the library in Local logout and provider sessions, the collage app changes its Sign out page. It now offers two buttons: Sign out, which ends only the collage app's session, and Sign out of the collage app and the photo service. On a shared computer, the second one is the button Ava wants. All domains, identifiers and tokens in these examples are fictional.
The collage app cannot end the photo service's session by itself. That session is a record on the photo service's servers, found through a cookieA small value that a website asks the browser to store and send back with later matching requests. Cookies commonly carry a session identifier, so the site can recognize an ongoing sign-in without your password. that belongs to auth.photos.example, which the collage app can neither read nor delete. It has to ask, and the request has to travel through Ava's browser, because that is where the photo service's cookie is. RP-Initiated Logout, where RP stands for the relying party that starts it, is the OpenID ConnectAn identity layer on top of OAuth 2.0 that lets an application sign people in with an account at another service. It adds the ID token, standard claims, and discovery to the OAuth exchange. specification for that request.
The collage app finds where to send the request in the photo service's discovery documentA JSON document that an OpenID Provider publishes at a well-known address under its issuer, listing its endpoints, where to find its signing keys, and its supported features so clients can configure themselves from one value., which includes this entry:
{
"issuer": "https://auth.photos.example",
"end_session_endpoint": "https://auth.photos.example/logout"
}This is the provider's end session endpoint, sometimes called its logout endpoint. On the collage app's side, the registration lists the addresses where the photo service may send the browser afterward, in the post_logout_redirect_uris field that Registering a relying party introduced. The collage app registered one address, its ordinary signed-out page, https://collage.example/signed-out.
When Ava selects the second button, the collage app does three things in order. It reads the ID tokenIn OpenID Connect, a signed JWT from the provider, addressed to one client, saying which account authenticated, when, and in answer to which request. It reports a sign-in and is not used to call APIs. it kept in her session record. It ends its own session, deleting the record and clearing the cookie, just as the ordinary Sign out does. Then it redirects her browser to the end session endpoint.
The specification leaves that order to the relying party. The collage app could keep its session until the photo service tells it the sign-out happened, but that would depend on things it cannot count on. Ava might decide at the photo service to stay signed in, or close the tab, and the notification might not arrive. Ending the local session first means the one sign-out the collage app controls has already happened, whatever follows.
The logout request
The collage app's redirect sends Ava's browser to this address, shown with its parameters on separate lines so we can read them:
https://auth.photos.example/logout
?id_token_hint=eyJhbGciOiJSUzI1NiIsImtpZCI6InBob3Rvcy1ycy0yMDI2LTA5IiwidHlwIjoiSldUIn0.eyJpc3MiOiJodHRwczovL2F1dGgucGhvdG9zLmV4YW1wbGUiLCJzdWIiOiJ1c2VyLTIwNDgi...
&post_logout_redirect_uri=https%3A%2F%2Fcollage.example%2Fsigned-out
&state=demo-signout-1The ID tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. is shortened for display. The specification defines six parameters for this request, and the collage app uses three of them:
| Parameter | What it does |
|---|---|
id_token_hint | An ID token the provider issued to this client, telling it which client, person, and session the request is about. Recommended. The collage app sends the ID token from Ava's 09:00 sign-in. |
post_logout_redirect_uri | Where to send the browser afterward. It must exactly match a registered address. |
state | A value returned unchanged with the browser, so the collage app can recognize its own request. Here demo-signout-1. |
client_id | Names the client. Mostly used when there is no ID token hint. If both are sent, the provider checks that they agree. |
logout_hint | A hint about who is signing out, in a form the provider defines, such as an email address or a username. |
ui_locales | Preferred languages for any page the provider shows, such as en-US. |
The ID token in the hint expired at 09:05, and it is now 09:40. That does not matter, because the hint is not being used as proof of anything. The photo service checks that it issued the token, by verifying its own signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message., and the specification asks it to accept an expired token when the client it names has a current or recent session. From aud, sub and sid it learns that the collage app is asking about Ava's session, demo-session-51. If that sid did not match the session in this browser, because someone else had signed in since, the photo service would treat the request as suspect and could refuse to act on it.
A hint in a URLA web address, such as https://photos.example/api/albums/42?limit=10. It names how to connect (https), the domain, the path to a particular page or resource, and any extra parameters after the question mark. is recorded wherever URLs are recorded, such as browser history and server logs. The base ID token here carries only identifiers and times, but a provider that copies profile claims into its ID tokens would put those into the address as well. Providers must accept the logout request as a form POST as well as a GET, so a relying party that wants the hint out of the address bar can send it from a form that submits itself.
At the end session endpoint, the photo service shows a page asking whether Ava wants to sign out of the photo service. The specification says a provider should normally ask, and must ask when the request has no valid ID token hint or names a session other than the one in this browser. Without that rule, any website could sign people out of the photo service with a link, which the specification treats as a form of denial of service: an attack that stops people using a service rather than stealing from it.
Ava confirms, and the photo service ends its session. It then notifies the other relying parties signed in through that session, using whichever notification each one registered. That includes the collage app, which registered for back-channel notices. Front-channel logout and Back-channel logout describe those notifications. Only then does it redirect the browser back. A request to sign out when the photo service has no session for that browser is not an error, so a second click, or a request after its session had already expired, simply succeeds.
Coming back
The photo service sends Ava's browser to the address the collage app named, adding the state value:
https://collage.example/signed-out?state=demo-signout-1It does so only because the address exactly matches one in the collage app's registration. Any other value, even one differing by a trailing slash, is an error: the provider performs no redirect and shows its own page, where it may still offer to sign Ava out. Without that rule, a logout link could send people from the photo service to any page an attacker chose, perhaps one asking them to sign in again. For the same reason, a request with a post-logout address but no ID token hint gets no redirect unless the provider has some other way to confirm that the address is legitimate. Sending client_id in that case at least tells the provider which registration to check the address against.
Registered post-logout address
https://collage.example/signed-out
Address and hint
- post_logout_redirect_uri
- /signed-out
- id_token_hint
- Sent
- Provider answers
- Redirect with state
Ava returns to the collage app
One character added
- post_logout_redirect_uri
- /signed-out/
- id_token_hint
- Sent
- Provider answers
- Its own page
No redirect
Address without a hint
- post_logout_redirect_uri
- /signed-out
- id_token_hint
- Missing
- Provider answers
- Its own page
No redirect unless confirmed
The return shows that the browser came back, not that the photo service ended its session.
Ava's session at the collage app no longer exists, so the collage app kept demo-signout-1 in a short-lived cookie of its own when it sent her away. When she returns, it compares the value. If it matches, the collage app deletes the cookie and shows a page that says she is signed out of the collage app, and that signing out of the photo service was a choice the photo service asked her about. If the value is missing or different, the collage app shows an ordinary signed-out page. Because the collage app ended its session before the redirect, a forged return has nothing to restore or change.
Notice what the page does not say. The return shows that Ava's browser came back, not that the photo service ended its session. She might have chosen to stay signed in there, and providers differ in whether they still send the browser back after a person declines. If the collage app ever needs to know that the photo service's session ended, that knowledge comes from a logout notification, not from this redirect.
Any other application Ava signed in to with her photo account at the library is signed out only if it registered for one of the photo service's logout notifications, and only if that notification reaches it. If the photo service did not offer an end session endpoint at all, the most the collage app could do is say that she is still signed in there and link to the photo service's own sign-out page.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Sign Ava out of the collage app and ask the provider to end its sessionSend real logout requests with id_token_hint, post_logout_redirect_uri and state, see when the tenant asks first, and watch it refuse a return address it never registered.