Skip to content

fix: Send back-channel logout from expired session cleanup - #142

Merged
patchandthat merged 3 commits into
RockSolidKnowledge:mainfrom
oleks9o6:fix/134-backchannel-logout-issuer
Oct 29, 2026
Merged

patchandthat merged 3 commits into
RockSolidKnowledge:mainfrom
oleks9o6:fix/134-backchannel-logout-issuer

Conversation

@oleks9o6

@oleks9o6 oleks9o6 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Back-channel logout notifications sent by the expired session cleanup now get their issuer from the session, so they no longer need an HttpContext.

SessionCleanupService runs without a request. DefaultBackChannelLogoutService read the issuer from HttpContext, threw, and the cleanup caught and logged the exception, so the clients in that batch were never notified. The issuer is already stored with the session, so it now travels through EndUserSessionEventContext, LogoutNotificationContext and BackChannelLogoutRequest (the Issuer names match Duende). The token uses request.Issuer when it is set and falls back to the current request otherwise, so end session is unchanged. DefaultSessionManagementService.RemoveSessionsAsync passes the session issuer too, since it can also run outside a request.

Closes #134

Type of change

  • Bug fix
  • Feature
  • Refactoring
  • Documentation
  • Other

Does this PR introduce a breaking change?

Does the change cause a breaking change to any of the following?

  • Changes to existing public APIs or DB schema
  • Changes which could cause existing behaviour to fail (eg. feature restrictions, changes to default values, stricter validation, etc)

Adds an Issuer property to LogoutNotificationContext, BackChannelLogoutRequest and EndUserSessionEventContext.

Testing

Unit tests cover each step the issuer passes through. A new integration test runs the expired session cleanup outside a request and checks the iss of the posted logout token; without the fix no token is posted. The existing end session tests cover the fallback. The full unit and integration suites pass.

LLM Usage

The src/ changes are written by me. The tests were drafted with Claude and reviewed by me.

Other context

Based on main, so it can go into a patch release without #140. #140 changes the same lines at the end of DefaultBackChannelLogoutService.CreateTokenAsync, so I'll update #140 once this is merged.

RemoveSessionsAsync called inside a request now uses the session's issuer rather than the current request's. They differ only when the session was created on another host or before IssuerUri changed, and then the session's issuer is the one the client knows.

🤖 Generated with Claude Code

@oleks9o6
oleks9o6 marked this pull request as ready for review October 28, 2026 13:11
@oleks9o6
oleks9o6 marked this pull request as draft October 28, 2026 13:12
@patchandthat

Copy link
Copy Markdown
Collaborator

@oleks9o6 The PR is marked as draft, is that accidental?

@oleks9o6

Copy link
Copy Markdown
Contributor Author

@oleks9o6 The PR is marked as draft, is that accidental?

@patchandthat Not accidental: it builds on #140 and includes its three commits, so I kept it as a draft until #140 is merged. It’s ready otherwise.

@patchandthat

Copy link
Copy Markdown
Collaborator

As this is a bugfix and non-breaking, I'd like to do a patch release soon with this in (& other bugfixes) but not #140. Is it possible to reorder them?

@oleks9o6

Copy link
Copy Markdown
Contributor Author

As this is a bugfix and non-breaking, I'd like to do a patch release soon with this in (& other bugfixes) but not #140. Is it possible to reorder them?

Sure, I'll do that.

@patchandthat

Copy link
Copy Markdown
Collaborator

Great, thank you.

@oleks9o6
oleks9o6 force-pushed the fix/134-backchannel-logout-issuer branch from 5c3304f to 74ea1cd Compare October 29, 2026 12:13
@oleks9o6
oleks9o6 marked this pull request as ready for review October 29, 2026 12:13
@patchandthat
patchandthat merged commit 2a86c66 into RockSolidKnowledge:main Oct 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backchannel logout sent outside of an HttpContext fails

2 participants