Local logout and provider sessions
An application's Sign out button ends the sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier. that application created, and nothing else. The identity providerA service that authenticates users and tells other applications about the sign-in, so those applications never handle the users' passwords. In OpenID Connect it is called an OpenID Provider.'s session stays in the browser, ready to sign the next person in, so deciding what logout should end is a design choice, and it starts with naming the provider's session.
What signing out ends
In Requesting stronger authentication, the collage app sent Ava back to the photo service for a passkeyA credential that your phone, computer or password manager creates for one website and keeps for you, unlocked with a fingerprint, face or PIN. Nothing you could type is sent, and it works only for the site it was made for, which helps it resist phishing. before she could download a board's full-resolution originals. 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. lessons so far have all been about getting in: proving who you are, carrying that proof to an application, and deciding whether it is strong or recent enough. Getting out raises problems of its own. All domains, identifiers and tokens in these examples are fictional.
Ava uses the collage app at collage.example, a relying partyAn application that accepts and relies on a sign-in from another service, the name used in OpenID Connect and for passkeys. SAML calls the same role a service provider. registered with the photo service as photo-collage. At 09:00 on 7 October she is at a computer in the public library. She chooses Continue with your photo account, signs in at the photo service, and the collage app validates 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 receives and starts its own session for her, as Establishing an application session described. At 09:40 she selects Sign out. The collage app shows its signed-out page, and she leaves.
The collage app's Sign out button ends the session the collage app created. As Staying signed in described, that takes two steps: deleting the session record on the collage app's server, and removing the 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 pointed to it. The response replaces the cookie with an empty one that has already expired:
HTTP/1.1 303 See Other
Location: https://collage.example/signed-out
Set-Cookie: __Host-collage-session=; Path=/; Max-Age=0; Secure; HttpOnly; SameSite=LaxThe empty cookie repeats the original attributes because a browser accepts a __Host- cookie, even one that deletes another, only with Secure, Path=/ and no Domain. Max-Age=0 tells the browser the cookie has already expired, so it removes it. Deleting the server record is the step that matters most. If a copy of the old cookie value survived somewhere, in the shared computer's memory or in a log, it would now find nothing.
Anything the collage app kept for the session goes with it: Ava's account, the issuerThe party that creates and signs a token, assertion, or certificate, named in a token's iss claim. A recipient must check that the issuer is exactly the one it expected and trusts., her subject, when she authenticated, and a copy of the 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. for signing out later.
One thing should survive. Ava also turned on the collage app's year-end collage, so the app holds a refresh tokenA longer-lived credential that a client sends to the authorization server, never to an API, to get new access tokens without asking the person again. that lets it collect her best photos every December. That connection is an authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. Ava granted, not a sign-in, and Offline access and refresh behavior explained why the two are kept apart. Signing out of a website should not quietly cancel next December's collage. Disconnecting the year-end collage is a separate choice the collage app offers on its own.
Ending the application's own session like this is called local logout. The collage app can do it completely and reliably, because it controls everything involved. It is also all the collage app has done.
The session Ava left behind
At 09:50 the next person at the library computer opens the collage app and selects Continue with your photo account. The collage app sends the browser to the photo service, exactly as it did for Ava. The photo service finds its own session cookie in the browser, set when Ava signed in at 08:59:45, and its policy accepts a session that recent without asking again. It issues a fresh ID token for Ava's subject, user-2048, and sends the browser back.
The collage app validates that token, and every check passes. The 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. is genuine, the issuer and audience are right, and the nonce matches the new attempt. The collage app signs a stranger in to Ava's account. Nothing was forged. The collage app ended the session it controlled and left the photo service's session running in the same browser.
The collage app's session
- Found through
- __Host-collage-session
- After Sign out
- Ended
- At 09:50
- Nothing to find
Local logout
The photo service's session
- Found through
- The photo service's cookie
- After Sign out
- Still active
- At 09:50
- Fresh ID token for user-2048
A stranger signed in to Ava's account
The year-end collage connection
- Found through
- A refresh token
- After Sign out
- Still active
- At 09:50
- Unchanged
Ends only when Ava disconnects
Nothing was forged. The collage app ended the session it controlled.
Single sign-on made Ava's morning easy, and the same convenience is at work here. Trust across systems pointed out that signing out of one application does not end the identity provider's session, or the sessions of other applications that relied on it. By the time Ava leaves the library, the browser can hold several sessions, each with its own owner:
| Session | Where it lives | What ends it |
|---|---|---|
| The collage app's session | A record on the collage app's server, found through the __Host-collage-session cookie for collage.example | The collage app's Sign out, or its idle or absolute timeout |
| The photo service's session | The photo service's own records, found through its cookie for auth.photos.example | Signing out at the photo service, or the photo service's own timeouts |
| Other applications' sessions | Each application Ava signed in to with her photo account during the visit | Each application separately |
The ID token is not on that list. Its exp passed at 09:05 without changing anything, because an ID token describes one sign-in and is not a session. Application accounts and sessions described these as independent lifetimes; the library is where that independence starts to hurt.
To coordinate across those sessions, the collage app and the photo service need a way to name the photo service's session, not just Ava's account. Providers that send logout notifications give each of their sessions an identifier and place it in ID tokens as the sid (session ID) claim. The photo service does this for clients registered for its notifications, so the collage app registers an address for the server-to-server logout notice that Back-channel logout describes. From then on an ID token like the one from Ava's 09:00 sign-in carries one more claim:
{
"iss": "https://auth.photos.example",
"sub": "user-2048",
"aud": "photo-collage",
"iat": 1791363600,
"exp": 1791363900,
"auth_time": 1791363585,
"nonce": "demo-nonce-9",
"sid": "demo-session-51"
}The value is opaque. The collage app does not try to parse it, and it means something only together with the issuer, since another provider could use the same string. Every application Ava signed in to through the same photo service session receives the same sid. The collage app stores it in the session record beside iss and sub. Later, a message about session demo-session-51 at https://auth.photos.example can be matched to Ava's session at the collage app, and a sign-out request from the collage app can tell the photo service which of its sessions it means. sid is a name, not a credential: holding it proves nothing, and it says nothing about whether the session is still active.
Choosing what logout means
The library shows what goes wrong when a sign-out ends less than Ava expects. The opposite happens too. At home, she might sign out of the collage app while she is still sorting photos at the photo service in another tab. If the collage app's Sign out also ended the photo service's session, she would be signed out there without warning, along with every other application that depended on it.
Consumer services usually keep local logout as the meaning of Sign out and offer the wider choice openly. The collage app can tell Ava that she is still signed in to the photo service and offer to sign her out there too, which matters most on a shared computer. The photo service, for its part, normally asks before ending its own session, because it knows better than the collage app what else she is using.
Organizations tend to want more. When a designer at Lantern Studio signs out of the portal at the end of the day, Lantern expects the session at its identity provider to end and the timesheets application to sign out as well, so the next person at the workstation finds nothing open. When a designer leaves Lantern, an administrator expects every one of their sessions to end at once, without waiting for the designer to click anything. Ending the sessions at several applications from one event is often called single logout.
OpenID Connect provides four mechanisms for these goals, each defined in its own specification. A relying party, or RP, is the application that relies on the provider's sign-in, such as the collage app:
| Mechanism | Who starts it | How the message travels |
|---|---|---|
| RP-initiated logout | The relying party, when the person asks | The browser is redirected to the provider's end session endpoint, which can end the provider's session |
| Front-channel logout | The provider, after its session ends | The browser loads each application's logout page in a hidden frame |
| Back-channel logout | The provider, after its session ends | The provider's server sends each application's server a signed logout token |
| Session management | The relying party, repeatedly | A script in the application's page asks a frame from the provider whether its session has changed |
The first answers the library problem: the collage app asking the photo service to end its session too. The other three carry the news from the provider to applications that did not start the sign-out. Which ones a deployment uses depends on its applications and on what its provider supports. None of them can guarantee that every message arrives, so each application keeps its own idle and absolute timeouts as a limit on how long a missed sign-out can matter.
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 watch the tenant sign her back inReproduce the library computer problem with two clients in one tenant, see that local logout leaves the provider session running, then end the provider session yourself and see what survives.