Skip to content

Revoke the session's authorizations at end-session - #3199

Merged
pournasserian merged 6 commits into
mainfrom
3198-end-session-revokes
Nov 16, 2026
Merged

pournasserian merged 6 commits into
mainfrom
3198-end-session-revokes

Conversation

@pournasserian

@pournasserian pournasserian commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Closes #3198

A logout cleared only the sign-in cookie, so a refresh token issued in that session could still be redeemed until it expired. A test reproduced this: after a confirmed logout the token endpoint still answered 200.

With this change:

  • Every new sign-in cookie, of either pool, carries a server session id in its properties (.fcms.server_session), which its renewals keep. The same user signing in again on the login page over a live cookie keeps it.
  • The authorize endpoint issues the code of a client without a consent step under an ad-hoc authorization marked with that id (fcms_server_session in the authorization's properties, so no migration). The identity token carries the id as sid.
  • UserSessions.EndAsync revokes every valid authorization of the user marked with the session, with its tokens. The refresh tokens are refused at once. The access tokens are refused from the next request on, since the bearer scheme checks the token and authorization entries on every request.

Where a session's authorizations now end:

  • The confirmed logout, or a logout with a hint of the session's own sid, whichever clients of the pool signed in through that session.
  • The member logout page.
  • Another user's sign-in over the cookie, which ends the first user's session in that browser.

What ends the cookie alone and revokes nothing:

  • The sign-outs that one cross-site GET can cause: prompt=login, max_age, AbsoluteSessionLifetime and a second factor the user's role now requires, at the authorize endpoint, whose request carries nothing secret, and the SSO provider's remote sign-out, which nothing authenticates. These are open in A re-authentication asked for at the authorize endpoint ends the sign-in cookie on a cross-site request #3203, The SSO provider's remote sign-out is not authenticated, so another site can end a user's sign-in #3204 and Tokens outlive the absolute session lifetime: the session start is the time of the authorize request #3205. A refresh token without amr=mfa is still refused by the token endpoint once the role requires two-factor.
  • A hint without the cookie's sid goes to the logout page, which asks. This covers an identity token of the same user from another session, another device or an earlier sign-in, a third-party client's token (a consent belongs to no session), and one from a sign-in before this change.
  • A logout without id_token_hint goes to the confirmation page as before, and nothing is revoked until the confirmed POST with its antiforgery token.
  • A cancelled or unconfirmed logout changes nothing.
  • A request without a live cookie revokes nothing, a valid hint included. Such a GET returns to the client without asking only when its hint is an identity token signed by this server with its algorithm (an expired one, or one a first logout revoked, still counts), issued to the client its client_id names, and the post_logout_redirect_uri it asks for is registered for that client. Any other hint goes to the logout page.
  • The user's other sessions (another browser, another device) stay.
  • A third-party client's consent stays, with its tokens.
  • A cookie from before this change has no id, so its logout ends the cookie alone, as before.

A browser logout therefore ends every client without a consent step that signed in through that browser, whatever offline_access it holds. A client that must outlive a browser logout is registered with RequireConsent. The specification and the release notes say this.

The response is unchanged, so it does not show whether a session existed. Sign-outs write no activity row, and the revocation adds none (#3207). FluentCMS.Testing builds its cookies through CmsSignInManager.MarkSignIn, the same path as the product.

Dependencies: none. The check of a hint's signature uses Microsoft.IdentityModel.JsonWebTokens, which OpenIddict already brings.

  • After /connect/logout for a session, a refresh token issued under that session's authorization is refused, in a test
  • The specification says what end-session revokes and what it leaves
  • The decision record of the admin's sign-in (0007) no longer names an unrevoked token after a completed logout as a known gap, or says what remains (the record is on feature/a1, not on main; it is updated there after this merges)

@pournasserian

Copy link
Copy Markdown
Member Author

Second review, at b70c300: one more fix round before this can merge.

Verified clean: the approach, TakeOverAsync (the old cookie's user and session are the ones ended; the id comes only from the protected cookie; the login post is antiforgery-protected; the pools are separate), the sid claim and the hint rule, attribution, no migration.

To change, because each lets another site revoke a signed-in user's tokens with one unconfirmed GET, where main ends the cookie at most:

  1. Revocation at /connect/authorize on prompt=login, max_age and the absolute session lifetime comes out, in both pools (probed: a foreign authorize request with prompt=login left the tab's refresh token invalid_grant). The absolute lifetime belongs with them: the session start of a token is the authorize time, so those tokens are still valid when the cookie's lifetime ends (Tokens outlive the absolute session lifetime: the session start is the time of the authorize request #3205). Revocation at a required second factor stays.
  2. Revocation at the SSO provider's remote sign-out comes out: nothing authenticates that request (The SSO provider's remote sign-out is not authenticated, so another site can end a user's sign-in #3204).
  3. The repeated logout without the cookie redirects only on a hint that is a token of this server.
  4. Must-not tests for 1 and 2, the test gaps of the review, and the specification, release note and PR body brought in line.

Follow-ups filed: #3202, #3203, #3204, #3205, #3207.

@pournasserian

Copy link
Copy Markdown
Member Author

Third review, at 184f70e: the removals are clean; one small round remains.

  1. The sign-out for a required second factor at /connect/authorize also ends the cookie alone: a plain cross-site authorize GET could otherwise revoke tokens of the session that the token endpoint still accepts (a session whose cookie became password-only on a remembered device). The authorize endpoint then revokes nothing.
  2. The logout GET without the cookie binds the hint to its client: a revoked identity token issued to one client was redirected to another client's registered post-logout URI. Nothing was ended; the redirect now needs the hint's own client.
  3. Tests for the member authorize endpoint and for hints signed by another key; the specification, release note and PR body corrected.

@pournasserian
pournasserian merged commit f8ff094 into main Nov 16, 2026
33 checks passed
@pournasserian
pournasserian deleted the 3198-end-session-revokes branch November 16, 2026 12:54
pournasserian added a commit that referenced this pull request Nov 16, 2026
…3216)

Brings `main` at f8ff094 into `feature/a1`, as a merge commit, so that the feature branch is tested with what `main` gained since the last sync:

- #3210: a take of the row lock that loses the first insert of a name rolls back before it reads the row (the `Templates` failure of #3200).
- #3208: the delivery cache tests deliver the grant's eviction before the shared-store reads (#3201).
- #3199: a confirmed logout revokes the authorizations of the session it ends (#3198).

One conflict, in the "Multi-instance as built" paragraph of `docs/planning/backend-technical-spec.md`: `main`'s text is taken, and the feature branch's own change to the paragraph on the commands in the reference host is kept.

With #3199 in, `docs/decisions/0007-admin-sign-in-flow.md` says what a logout ends: an unconfirmed one leaves the server's session and its tokens; a confirmed one ends the session and revokes every authorization issued in it; a sign-in from before #3198 and a third-party client's consent are not ended.

## Dependencies

None.

Part of #3152.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:identity Users, authorization server, API keys and members type:bug Defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

End-session does not revoke the session's authorization, so a refresh token outlives a sign-out

1 participant