fix: skip OIDC end-session after password login for OAuth2 users - #38439
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an OIDC logout misredirect by tracking how the current session authenticated (password vs OAuth2) and using that session-scoped method—rather than the account’s persisted LoginType—to decide whether to perform RP-initiated OIDC logout.
Changes:
- Add a session key (
KeySignInMethod) to record whether the current session signed in via password or OAuth2. - Update logout redirect logic to prefer the session sign-in method, with a fallback to legacy
LoginTypebehavior when the key is absent. - Extend tests to cover OAuth2-session logout redirect, legacy fallback, and password-session non-OIDC logout.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| routers/web/auth/oauth.go | Sets KeySignInMethod=oauth2 for OAuth2 sign-in (including pre-2FA session). |
| routers/web/auth/linkaccount.go | Sets KeySignInMethod during link-account 2FA session (currently set to OAuth2; should be password for password-authenticated linking). |
| routers/web/auth/auth.go | Preserves/sets sign-in method into the authenticated session and gates OIDC end-session redirect on it. |
| routers/web/auth/auth_test.go | Adds subtests for OAuth2 session redirect, legacy fallback, and password session skipping OIDC logout. |
| modules/session/key.go | Introduces KeySignInMethod and method constants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Friendly ping for review when you have a moment. Happy to rebase or adjust if anything looks off. |
c25e837 to
4ab87bb
Compare
|
@Otto-Deviant1904 no, don't do that, don't force push, don't revert to your commit. Have you reviewed my change? What's wrong? |
Track the session sign-in method so logout only hits the OIDC end_session_endpoint when this session authenticated via OAuth2. Co-authored-by: Cursor <cursoragent@cursor.com>
4ab87bb to
2358d4e
Compare
|
Sorry - that force-push was a mistake. I was rebasing onto current main and overwrote your cleanup. Restored your |
|
Don't rebase or force-push https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md#maintaining-open-prs |
) (#38666) Backport #38439 by @Otto-Deviant1904 Fixes #38209 OAuth2-linked accounts that sign in via the password form were still redirected to the provider end_session_endpoint on logout because the redirect was keyed off account LoginType. Store the session sign-in method (password vs oauth2) and only use RP-initiated OIDC logout when this session was authenticated via OAuth2. Sessions without the new key keep the previous LoginType behavior. Co-authored-by: Harsh Satyajit Thakur <f20240223@goa.bits-pilani.ac.in> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* 'main' of https://github.com/go-gitea/gitea: chore: tweak AGENTS.md (go-gitea#38702) [skip ci] Updated translations via Crowdin fix: avoid markup render panic (go-gitea#38698) fix(ui): too many participants shown in commit avatar stacks (go-gitea#38689) [skip ci] Updated translations via Crowdin chore: still keep ctx in git.Repository struct for cat-file batch command (go-gitea#38684) feat: Add support for dynamic matrix evaluation in Gitea Actions workflows (go-gitea#36564) fix: Alpine registry APKINDEX.tar.gz returns 405 for HEAD requests [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT] (go-gitea#38686) fix: repo home page 500 due to the timeout of "get last commit info" (go-gitea#38678) [skip ci] Updated translations via Crowdin docs: Update Changelog for release v1.27.1 (go-gitea#38670) refactor(git): clarify GetBranch behavior to make it only gets an existing branch (go-gitea#38662) chore(deps): update dependencies (go-gitea#38660) feat: Add max-parallel Support for Gitea Actions (go-gitea#36357) fix: skip OIDC end-session after password login for OAuth2 users (go-gitea#38439) ci: set AWS_REGION for Cloudflare R2 upload steps (go-gitea#38658) fix: make Actions log parser support multiple line message encoding (go-gitea#38659) test(pubsub): stop racing the Redis SUBSCRIBE ack (go-gitea#38661) chore(ci): fix renovate custom manager regex (go-gitea#38656) feat: Replace SSE with WebSocket for UI notifications (go-gitea#36965)
* main: chore: tweak AGENTS.md (go-gitea#38702) [skip ci] Updated translations via Crowdin fix: avoid markup render panic (go-gitea#38698) fix(ui): too many participants shown in commit avatar stacks (go-gitea#38689) [skip ci] Updated translations via Crowdin chore: still keep ctx in git.Repository struct for cat-file batch command (go-gitea#38684) feat: Add support for dynamic matrix evaluation in Gitea Actions workflows (go-gitea#36564) fix: Alpine registry APKINDEX.tar.gz returns 405 for HEAD requests [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT] (go-gitea#38686) fix: repo home page 500 due to the timeout of "get last commit info" (go-gitea#38678) [skip ci] Updated translations via Crowdin docs: Update Changelog for release v1.27.1 (go-gitea#38670) refactor(git): clarify GetBranch behavior to make it only gets an existing branch (go-gitea#38662) chore(deps): update dependencies (go-gitea#38660) feat: Add max-parallel Support for Gitea Actions (go-gitea#36357) fix: skip OIDC end-session after password login for OAuth2 users (go-gitea#38439) ci: set AWS_REGION for Cloudflare R2 upload steps (go-gitea#38658) fix: make Actions log parser support multiple line message encoding (go-gitea#38659) test(pubsub): stop racing the Redis SUBSCRIBE ack (go-gitea#38661) chore(ci): fix renovate custom manager regex (go-gitea#38656) feat: Replace SSE with WebSocket for UI notifications (go-gitea#36965)
Fixes #38209
OAuth2-linked accounts that sign in via the password form were still
redirected to the provider end_session_endpoint on logout because the
redirect was keyed off account LoginType.
Store the session sign-in method (password vs oauth2) and only use
RP-initiated OIDC logout when this session was authenticated via OAuth2.
Sessions without the new key keep the previous LoginType behavior.
AI disclosure: assisted with investigation, implementation, and tests.
I reviewed and verified the change and will handle review feedback myself.
Made with Cursor