Front-channel logout and browser session checks
When the provider's session ends, the applications that shared it still need to hear about it. Two older specifications carry that news through the browser, one by loading each application's logout page in a hidden frame and one by letting the application's page keep asking, and both depend on cross-site frames that browsers now restrict.
Logging out through the browser
Lantern Studio's designers use two applications through Lantern's 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. at https://idp.lantern.example: the project portal at https://portal.lantern.example, and the timesheets application at https://time.lantern.example. A designer signs in once in the morning, and single sign-onSigning in once and then using several applications without entering credentials again, usually because they all rely on the same identity provider. carries them into both. All domains, identifiers and tokens in these examples are fictional.
At the end of Thursday, designer-42 selects Sign out in the portal on a shared workstation in the studio. The portal uses RP-initiated logout, as the collage app did, and Lantern's identity provider ends its session. The timesheets application, still open in another tab, knows nothing about it. Its session would last until its own timeout, and the next person at the workstation could open that tab and record hours as designer-42.
Only the provider knows that both applications were part of the session it just ended. Front-Channel Logout lets it pass the news on through the browser that is already at its sign-out page. A second specification, Session Management, works the other way round: the application keeps asking, from inside the browser, whether anything has changed at the provider. Both carry their signal through a frame from one site inside a page from another, and that is why both so often fail.
To notify anyone, the provider has to remember whom to notify. Lantern's provider records each application that signs in through each of its sessions. For the session it identifies as demo-session-58, the list holds lantern-portal and lantern-timesheets.
Each application has registered a front-channel logout URI, a page on its own site that ends its session when it is loaded. The timesheets registration includes:
{
"client_id": "lantern-timesheets",
"frontchannel_logout_uri": "https://time.lantern.example/logout/front-channel",
"frontchannel_logout_session_required": true
}The address must use the same scheme, host, and port as one of the application's registered redirect URIs, which ties it to a site the registration already trusts. frontchannel_logout_session_required asks the provider to add two query parameters when it loads the page: iss, its issuer identifierThe 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., and sid, the session that ended. A provider that can send them also puts the same sid in the ID tokens it issues, so each application already holds the value in its session record. Lantern's provider uses one value for every application signed in through a browser session. Another provider might give each application its own; either way, an application only compares the value with the one it stored.
After ending its session, the provider shows a signed-out page. Inside it is a hidden frame for each application on the list:
<p>You are signed out of Lantern.</p>
<iframe hidden src="https://portal.lantern.example/logout/front-channel?iss=https%3A%2F%2Fidp.lantern.example&sid=demo-session-58"></iframe>
<iframe hidden src="https://time.lantern.example/logout/front-channel?iss=https%3A%2F%2Fidp.lantern.example&sid=demo-session-58"></iframe>The browser loads every frame at once, and each request carries the provider's issuer and the session ID to one application. The portal is on the list even though it started the sign-out, because RP-initiated logout includes the initiating application in these notifications. It has already ended its own session, and a logout request for a session that is already gone counts as a success. Once the frames have loaded, the provider sends the browser on to the portal's registered post-logout address.
Each frame is an ordinary page load inside the provider's page, so the browser decides which cookies go with it by the rules about sites and SameSite from What browsers add. For Lantern those rules are generous. For most relying parties they are not, as Why browser signals fail shows.
The logout page
When the request reaches https://time.lantern.example/logout/front-channel, the timesheets application:
- Checks that
issis exactlyhttps://idp.lantern.example, the issuer it is configured to trust. - Looks for sessions whose stored issuer and
sidmatch. The specification allows an application to ignore a request that matches none of its current or recent sessions. - Ends each matching session on its server, and clears its session 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. and anything it keeps in browser storage for that session.
- Responds with a short page and tells caches not to store it.
HTTP/1.1 200 OK
Content-Type: text/html
Cache-Control: no-store
Content-Security-Policy: frame-ancestors https://idp.lantern.example
Set-Cookie: __Host-timesheets-session=; Path=/; Max-Age=0; Secure; HttpOnly; SameSite=LaxCache-Control: no-store keeps a stored copy of this page from answering a later logout request before it reaches the application. The frame-ancestors rule in the Content Security Policy lets only Lantern's provider show the page in a frame. The browser applies that rule to the response, though, after the request has reached timesheets and the session is already gone. It decides where the page may be displayed, not who may cause a logout, so it cannot be the page's protection.
Notice what the page relies on. The request is an ordinary GET, which any website can cause. A frame or image tag on another site would arrive without timesheets' SameSite=Lax cookie, but following a link to the logout address from another site sends it. If the logout page simply ended whatever session its cookie pointed to, any page designer-42 visited could sign them out of timesheets with such a link. Matching sid limits the request to the session the provider named, and providers generate session IDs with enough randomness that nobody can guess someone else's. A stranger without the value has nothing useful to send.
Watching the provider's session
Front-channel logout waits for the provider to announce that a session ended, and the announcement goes out only from a browser standing on the provider's signed-out page. Timesheets wants more than that. It runs a timer in the browser while a designer works on a project, and if designer-42 signs out of Lantern in another tab, it would like to notice within seconds, stop the timer, and show a signed-out screen. Session Management lets it watch instead of wait.
Watching starts at sign-in. A provider that supports it adds a parameter to the authenticationChecking evidence that someone, or some application, controls an account, such as a password or a passkey. It establishes which account is being used, not what that account may do. response, beside the code and state:
https://time.lantern.example/signin/callback
?code=demo-code-31
&state=demo-time-4
&session_state=3c9d4e81a7...e5f0.demo-salt-4The session state value is shortened. session_state represents designer-42's sign-in state at Lantern's provider, as seen by this one application. To timesheets it is opaque: the application stores it and sends it back later, nothing more.
The provider also lists one more address in its 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.:
"check_session_iframe": "https://idp.lantern.example/check-session"This page is meant to be loaded in a hidden frame inside the application's own page, so that a small piece of the provider runs alongside the application in the browser. Every few seconds, the application asks that piece of the provider whether the session state it holds is still current. Front-channel logout put the application's page in a frame inside the provider's page. Session Management puts the provider's page in a frame inside the application's.
How the check works
The timesheets page holds two hidden frames. One loads the provider's check session page. The other is timesheets' own, and it does the asking. It uses the browser's postMessage interface, which lets pages from different origins, as What browsers add defined them, exchange messages, each naming the origin it expects on the other side. The message is the client ID and the stored session state, separated by a space. A simplified version of the asking frame's script looks like this:
const providerOrigin = 'https://idp.lantern.example';
const message = 'lantern-timesheets ' + sessionState;
setInterval(() => {
providerFrame.postMessage(message, providerOrigin);
}, 5000);
window.addEventListener('message', (event) => {
if (event.origin !== providerOrigin) return; // answers only from the provider
if (event.data === 'changed') checkWithProvider();
});The provider's frame runs on the provider's own origin, so it can read the provider's browser state: a value kept in a cookie or in web storage that the provider changes whenever someone signs in or out there. It recalculates the session state from the client ID, the origin the message came from, that browser state, and the saltA random value stored with each password hash and mixed into the calculation, so that two people with the same password get different stored hashes. It does not need to be secret. at the end of the value it received, typically as a hashTurning data into a short, fixed-size value called a hash, in a way that cannot be reversed and where changing one character changes the result completely. Services store password hashes instead of passwords, and signatures are made over a hash.. Then it replies with one word:
| Reply | Meaning |
|---|---|
unchanged | The recalculated value matches. Nothing has changed, and the application keeps polling. |
changed | The values differ. Something happened at the provider, and the application must find out what. |
error | The message was malformed. The application must not answer it with a prompt=none request, which could loop. |
Both frames check origins. The provider's frame answers only messages from origins it expects, and the application's frame accepts replies only from the provider's origin, so another page cannot feed it a false unchanged. The polling itself never leaves the browser. That was the point of the design: knowing about a sign-out within seconds without sending the provider a request every few seconds.
changed is not a sign-out. It means only that the provider's browser state is different. Perhaps designer-42 signed out, perhaps someone else signed in, or perhaps something changed that has nothing to do with this application; the specification warns that some providers report changes to other sessions too. So timesheets asks the provider properly. It sends an authentication request with prompt=none, and designer-42's earlier 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. as id_token_hint. If a new 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. comes back for designer-42, timesheets stores the new session state and carries on. If the provider answers login_required, or returns an ID token for someone else, timesheets treats it as designer-42 signing out: it ends the session, stops the timer, and shows the signed-out screen.
Why browser signals fail
Every step of front-channel logout happens in the designer's browser, and the provider learns nothing about the result. A frame from another origin does not report whether the page inside it succeeded, so the provider can tell at most that something loaded. If designer-42 closes the tab before the frames finish, the network drops, or an application is briefly down, the request is lost. Nobody retries it, because nobody knows it failed. A sign-out that never reaches the provider's signed-out page, such as an administrator ending the session, loads no frames at all.
Lantern's setup is also kinder than most. Browsers decide what counts as third-party by site, the registrable domain such as lantern.example, not by the full host name. Lantern's provider, portal, and timesheets are all subdomains of lantern.example, so their frames are same-site. The browser sends each application its cookies, storage inside a frame is the same storage the application sees in its own tab, and the provider's check session frame inside timesheets reads the provider's own state.
Now imagine the collage app had registered for front-channel logout with the photo service instead of back-channel. Its logout page at collage.example would load in a frame inside a page at auth.photos.example, a different site. The collage app's __Host-collage-session cookie is marked SameSite=Lax, and browsers do not send a Lax cookie with a request for a cross-site frame. Changing it to SameSite=None would expose it to every cross-site request, which is what Lax exists to prevent, and it still would not be enough. Some major browsers block third-party cookies by default or keep a separate cookie jar for each top-level site, the others let people turn third-party cookies off, and current browsers partition web storage such as localStorage in cross-site frames. The collage app's frame would see none of its own browser state.
The collage app's logout page would still have one way to do its job. Its sessions live on its server, and when Ava signed in it stored the issuer and sid beside her session. The request in the frame carries both, so the collage app can find and end Ava's session without any cookie at all. An application that keeps its whole session in the browser has no such way out: its frame sees an empty, partitioned copy of storage, and the session in its own tab carries on.
Same site as the provider
- Frame inside
- idp.lantern.example
- Session cookie
- Arrives
- Finds the session by
- Cookie, then iss and sid
Session ends
Cross-site frame
- Frame inside
- auth.photos.example
- Session cookie
- Withheld
- Finds the session by
- Its cookie
Ava's session keeps running
Cross-site frame
- Frame inside
- auth.photos.example
- Session cookie
- Withheld
- Finds the session by
- iss and sid on its server
Session ends without any cookie
A frame from another origin does not report whether the page inside it succeeded, so nobody retries a lost request.
Session Management breaks the same way, from the other side. If the collage app used it with the photo service, the provider's check session frame would be a cross-site frame inside a page at collage.example. Browsers that block third-party cookies withhold the photo service's cookie from it, and browsers that partition cookies and storage give it a separate, empty set, distinct from the one the photo service sees when Ava visits it directly. Either way, the frame cannot see her session.
The specification describes the result. A provider that keeps its browser state in a cookie may answer changed to every message, and an application that obediently checks again each time loops through silent sign-in requests without end. Those checks fail too, because a prompt=none request made in a hidden frame is cross-site as well, which is why Prompt and account selection called silent checks in hidden frames unreliable. The specification recommends defensive code that detects the situation and tells the person, such as at most one silent check per page visit followed by a signed-out screen that waits for them, and leaves the details to each deployment, because browser behavior keeps changing. Even where it works, Session Management reaches only browser tabs that are open and running the script. It cannot end a session on a closed laptop or in a mobile app, and the application's server learns nothing unless the page reports back.
From outside, these failures look alike: a blank frame, a session that did not end, or a page that keeps asking. They need different fixes. A frame that never loaded calls for a channel that does not depend on the browser. A logout request that arrived without its cookie calls for a logout page that finds sessions by iss and sid. A check session frame that answers changed whoever is signed in calls for a different way of watching. Telling them apart starts with whether the request reached the application's server, or the provider's, at all.
What to rely on instead
Applications today usually combine other tools. Back-channel logout has the provider tell each application's server directly, so it ends server-side sessions whether or not a browser is open. Idle and absolute timeouts bound how long a missed message matters. When an application's own session ends, it can send the browser to the provider as a full-page redirect, with prompt=none if it wants no interruption; at the top level, the provider's cookies are first-party, so its answer reflects the session it really holds. And a browser application like timesheets can still notice a sign-out quickly by asking its own server whether its session is valid, which back-channel logout keeps up to date.
The browser signals have not disappeared. Front-channel logout still serves organizations like Lantern, whose applications share a site with their identity provider, as a quick way to clear browser state when it works. You will still meet check_session_iframe in provider metadata, and older single-page applications and client libraries still offer Session Management as an option. Knowing how each works explains why one of them might loop through sign-in requests, or fail to notice a sign-out at all. For a sign-out that must happen, such as ending a departing employee's sessions, the provider needs a path that does not depend on a browser.
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
- Send both browser logout signals and see where they failRegister front-channel logout and the session check frame, watch the signed-out page load each app's logout page and your own page hear changed, then see what a cross-site frame loses.