fix(login): treat already-logged-out as success in backchannel logout (#1430)#1431
Conversation
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>
|
Thanks ! |
julien-nc
left a comment
There was a problem hiding this comment.
Thanks a lot. Small adjustments and let's get this in!
| // out is a success). Same rationale as the (sid,iss) | ||
| // branch above. | ||
| $this->logger->debug( | ||
| '[BackchannelLogout] no RP sessions for (sub,iss) — treating as already-logged-out per spec', |
There was a problem hiding this comment.
| '[BackchannelLogout] no RP sessions for (sub,iss) — treating as already-logged-out per spec', | |
| '[BackchannelLogout] no RP sessions for (sub,iss) — treating as already-logged-out', |
| // state — the RP session being gone — is already true. | ||
| // See https://openid.net/specs/openid-connect-backchannel-1_0.html#BCActions | ||
| $this->logger->debug( | ||
| '[BackchannelLogout] no RP session for (sid,iss) — treating as already-logged-out per spec', |
There was a problem hiding this comment.
| '[BackchannelLogout] no RP session for (sid,iss) — treating as already-logged-out per spec', | |
| '[BackchannelLogout] no RP session for (sid,iss) — treating as already-logged-out', |
| // 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." Returning 400 here | ||
| // causes IdPs (e.g. LemonLDAP, Keycloak) to surface a | ||
| // confusing error to the user even though the desired | ||
| // state — the RP session being gone — is already true. | ||
| // See https://openid.net/specs/openid-connect-backchannel-1_0.html#BCActions |
There was a problem hiding this comment.
Can you make this a little bit shorter? The link + a very brief explanation should be enough.
Address julien-nc's review:
- Shorten the long rationale comment to a one-liner with the spec
link, per inline review at lib/Controller/LoginController.php:940.
- Drop the redundant ' per spec' suffix from both already-logged-out
debug log lines (lib/Controller/LoginController.php:942 and :972),
matching the suggested edits.
Behaviour is unchanged — only comment / log message wording.
|
Thanks for the review @julien-nc — applied all three suggestions in aa87b8f: comment block shortened to a single line + spec link, and the redundant |
|
Thanks for the adjustments. Could you sign your commits like indicated in the DCO check output? |
Address julien-nc's review:
- Shorten the long rationale comment to a one-liner with the spec
link, per inline review at lib/Controller/LoginController.php:940.
- Drop the redundant ' per spec' suffix from both already-logged-out
debug log lines (lib/Controller/LoginController.php:942 and :972),
matching the suggested edits.
Behaviour is unchanged — only comment / log message wording.
Signed-off-by: SAY-5 <say.apm35@gmail.com>
aa87b8f to
abe6772
Compare
|
@julien-nc the DCO check is currently passing — both commits on this branch carry |
|
Thank you! |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Closes #1430.
Summary
Per OIDC Backchannel Logout 1.0 §2.6:
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:
findSessionBySid→DoesNotExistException⇒ returnHTTP/200 OK+ debug log.findSessionsBySubAndIssreturns empty ⇒ returnHTTP/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
logleveltodebugand see the[BackchannelLogout]line.Mirrors the proposed fix in the issue and the spec citation.
Test plan
LoginControllerTestexists intests/unit/Controller/today, and the existing integration runner undertests/integration/does not cover the backchannel flow. The change is two short branches that swap agetBackchannelLogoutErrorResponse()fornew JSONResponse([], Http::STATUS_OK)plus a debug log; both branches are syntactically equivalent to the existingreturn new JSONResponse([], Http::STATUS_OK)at the end of the success path.git diff --checkclean.Notes