feat(oauth2): support prompt=select_account #182
No reviewers
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
codefloe/forgejo-codefloe!182
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/oauth-select-account"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add OpenID Connect
prompt=select_accountsupport to the OAuth2 authorize endpoint, so OAuth2 clients can let the user choose which CodeFloe account to continue with.The motivating client is
discourse-codefloe-auth, which uses it to switch the Discourse account a user is logged in with.What changes
/login/oauth/authorizeshows an account chooser whenpromptcontainsselect_account.It lists the signed-in account, the other accounts in the session's account switcher (inactive or login-prohibited ones are hidden), "Use another account", and Cancel.
The client ID, redirect URI, response type and PKCE checks still run first and fail exactly as before; any other
promptvalue is still ignored.POST /login/oauth/select_account:uidswitches the session to that account (only accounts already in the session's switcher list; anything else is 400) and redirects back to the authorize URL withoutprompt.add=1starts the existing add-account login and returns to the authorize URL afterwards.redirect_tomust be the local/login/oauth/authorizeURL (underAppSubURL); anything else is 400.access_deniedto the client through the existing grant-denial path.switchToAccountandbeginAddAccount, shared by the navbar switcher and the new endpoint; the navbar endpoints keep their responses.redirect_tocookie, so an abandoned add from the chooser cannot later send the user to an OAuth client.Tests
tests/integration/oauth_select_account_test.go(chooser rendering, combined prompts, POST authorize, other prompts unchanged, invalid client, switching and code issued for the chosen account, unlisted accounts, foreign redirects, prohibited accounts, add flow, Cancel, stale redirect cookie).routers/web/auth/oauth_select_account_test.gofor the redirect helpers with and withoutAppSubURL.TestSelectAccount*,TestAuthorize*,TestAccountSwitch*,TestOAuth*pass on sqlite.