Skip to content

resolve logout token subject:sessions for the idp backchannel logout#2328

Open
dragonchaser wants to merge 9 commits intoopencloud-eu:mainfrom
dragonchaser:fix-backchannel-logout
Open

resolve logout token subject:sessions for the idp backchannel logout#2328
dragonchaser wants to merge 9 commits intoopencloud-eu:mainfrom
dragonchaser:fix-backchannel-logout

Conversation

@dragonchaser
Copy link
Member

@dragonchaser dragonchaser commented Feb 12, 2026

Description

the backchannel logout only considers the logout token sessionId, as mentioned by the spec,
the sessionId is optional if the subject exists.

The current implementation ignores the subject and fails if the sessionId is not part of the logoutToken.
A more detailed description of the problem and how to reproduce it can be found here.

Related Issue

Motivation and Context

from the spec:

A Logout Token MUST contain either a sub or a sid Claim, and MAY contain both. If a sid Claim is not present, the intent is that all sessions at the RP for the End-User identified by the iss and sub Claims be logged out.

Known side-effects

  • keyCloak "Sign out all active sessions" does not send a backchannel logout request,
    as the devs mention, this may lead to thousands of backchannel logout requests,
    therefore, they recommend a short token lifetime.
    OIDC: Backchannel logout not being called when using Sign out all Session in Keycloak  keycloak/keycloak#27342 (comment)

  • keyCloak user self-service portal, "Sign out all devices" may not send a backchannel
    logout request for each session, it's not mentionex explicitly,
    but maybe the reason for that is the same as for "Sign out all active sessions"
    to prevent a flood of backchannel logout requests.

  • if the keyCloak setting "Backchannel logout session required" is disabled (or the token has no session id),
    we resolve the session by the subject which can lead to multiple session records (subject.*),
    we then send a logout event (sse) to each connected client and delete our stored cache record (subject.session & claim).
    all sessions besides the one that triggered the backchannel logout continue to exist in the identity provider,
    so the user will not be fully logged out until all sessions are logged out or expired.
    this leads to the situation that web renders the logout view even if the instance is not fully logged out yet.

Things to pay special attention to during the review

  • services/proxy/pkg/middleware/oidc_auth.go
    • format of the cache key
      • {key: ".sessionId"} => used for *.sessionId
      • {key: "subject.sessionId"} => used for subject.*
  • services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout.go
    • suffix key matching and lookup
    • prefix key matching and lookup
    • suspicious query detection
  • services/proxy/pkg/staticroutes/backchannellogout.go
    • error handling (all cases and return values are ok?)

ToDos:

  • the spec mentions by the iss and sub Claims ..., we don't do that?
  • we use the memory cache store by default, should we switch it to nats?

Questions

  • why don't we just store the claim records in the cache and use it for everything?

How Has This Been Tested?

  • unit tests
  • local keyCloak installation & multiple clients & multiple cache stores (memory, nats-kv)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

@dragonchaser dragonchaser force-pushed the fix-backchannel-logout branch from a5ff70e to 8cd6107 Compare February 12, 2026 13:10
@dragonchaser dragonchaser force-pushed the fix-backchannel-logout branch from 8cd6107 to c051e6e Compare February 12, 2026 13:18
@fschade fschade force-pushed the fix-backchannel-logout branch from c67804e to 6f8c92f Compare February 13, 2026 19:47
@fschade
Copy link
Member

fschade commented Feb 13, 2026

toDo:

  • using nats kv by default is ok?
  • what should we do if the token contains a session id and a subject
  • check comment toDos

@fschade fschade force-pushed the fix-backchannel-logout branch 2 times, most recently from a10347c to ae9427a Compare February 13, 2026 20:20
dragonchaser and others added 4 commits February 13, 2026 23:48
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
Co-authored-by: Michael Barz <m.barz@opencloud.eu>
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
Co-authored-by: Jörn Dreyer <j.dreyer@opencloud.eu>
Co-authored-by: Michael Barz <m.barz@opencloud.eu>
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
@fschade fschade force-pushed the fix-backchannel-logout branch from ae9427a to 1e53cc9 Compare February 13, 2026 23:07
@fschade
Copy link
Member

fschade commented Feb 13, 2026

A few minor things here and there, but it should be fine for now.

logout.mp4

@fschade fschade force-pushed the fix-backchannel-logout branch 11 times, most recently from ed4d19f to 455c703 Compare February 15, 2026 16:43
@fschade fschade force-pushed the fix-backchannel-logout branch from 455c703 to da5d1d4 Compare February 16, 2026 10:01
@fschade fschade changed the title add additional validation to logout token resolve logout token subject:sessions for the idp backchannel logout Feb 16, 2026
@fschade fschade self-assigned this Feb 16, 2026
@github-project-automation github-project-automation bot moved this to Qualification in OpenCloud Team Board Feb 16, 2026
@fschade fschade moved this from Qualification to In Progress in OpenCloud Team Board Feb 16, 2026
@fschade fschade marked this pull request as ready for review February 16, 2026 13:15
@fschade
Copy link
Member

fschade commented Feb 16, 2026

i updated the issue description, hope it makes sense

@sonarqubecloud
Copy link

@fschade fschade requested review from micbar and rhafer February 17, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants