Skip to content

fix(login): treat already-logged-out as success in backchannel logout (#1430)#1431

Open
SAY-5 wants to merge 1 commit intonextcloud:mainfrom
SAY-5:fix/backchannel-logout-already-logged-out-1430
Open

fix(login): treat already-logged-out as success in backchannel logout (#1430)#1431
SAY-5 wants to merge 1 commit intonextcloud:mainfrom
SAY-5:fix/backchannel-logout-already-logged-out-1430

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 28, 2026

Closes #1430.

Summary

Per OIDC Backchannel Logout 1.0 §2.6:

If the identified End-User is already logged out at the RP when the logout request is received, the logout is considered to have succeeded.

Today backChannelLogout() returns HTTP/400 when the (sid, iss) or (sub, iss) lookup yields no matching session, which is exactly the already-logged-out case the spec calls out as a success. The reporter (running LemonLDAP) sees a confusing error surfaced on the IdP UI even though the desired state — the RP session being gone — is already true. The same shape would happen with Keycloak, Authelia, etc.

Change

Only the two "session not found" paths flip to HTTP/200:

  • findSessionBySidDoesNotExistException ⇒ return HTTP/200 OK + debug log.
  • findSessionsBySubAndIss returns empty ⇒ return HTTP/200 OK + debug log.

The other validation branches in the same method — invalid issuer, invalid signature, malformed token, missing claims, multiple-sessions-found — keep their HTTP/400 responses. Operators that need visibility into already-logged-out backchannel calls can flip Nextcloud's loglevel to debug and see the [BackchannelLogout] line.

Mirrors the proposed fix in the issue and the spec citation.

Test plan

  • No LoginControllerTest exists in tests/unit/Controller/ today, and the existing integration runner under tests/integration/ does not cover the backchannel flow. The change is two short branches that swap a getBackchannelLogoutErrorResponse() for new JSONResponse([], Http::STATUS_OK) plus a debug log; both branches are syntactically equivalent to the existing return new JSONResponse([], Http::STATUS_OK) at the end of the success path.
  • Ran git diff --check clean.
  • Verified the spec citation against the linked RFC section.

Notes

  • This is the spec-compliant behavior; existing IdPs will start receiving cleaner success responses for the already-logged-out case.
  • The optional "debug checkbox" the reporter floated is left for follow-up — the spec is unambiguous, so a per-provider opt-out adds configuration surface for no clear benefit.

Closes nextcloud#1430.

OIDC Backchannel Logout 1.0 §2.6 says:

  'If the identified End-User is already logged out at the RP when
   the logout request is received, the logout is considered to have
   succeeded.'

Today `backChannelLogout()` returns HTTP/400 when the (sid, iss)
or (sub, iss) lookup yields no matching session, even though that
is exactly the already-logged-out case the spec calls out as a
*success*. IdPs (e.g. LemonLDAP, Keycloak) surface this 400 to the
end user and log a spurious error.

The other validation branches in this method — invalid issuer,
invalid signature, missing claims, malformed token — keep their
HTTP/400 responses. Only the two 'session not found' paths flip
to HTTP/200 + a debug log so administrators can still trace what
happened.

See https://openid.net/specs/openid-connect-backchannel-1_0.html#BCActions

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@Spitfireap
Copy link
Copy Markdown

Thanks !
tested on v33.0.2 without any issue. It's working as intended

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.

RP initiated logout makes backchannel logout throw an HTTP/400 error

2 participants