docs(auth): extend OAuth2Handler coverage in store-interfaces and sentinel errors#209
Merged
Merged
Conversation
…tinel errors - store-interfaces.md: mention OAuth2Handler alongside OIDCHandler in the CreateOIDCUser race-retry note (both use the shared findOrCreateUser helper) - store-interfaces.md: update OIDCLinkNonceStore description to list both OIDCHandler and OAuth2Handler as consumers of the store - auth/index.md: add oauth2_link_error=Failed+to+link to the ErrOIDCSubjectAlreadyLinked sentinel description so it covers both handlers Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates auth package documentation to reflect that OAuth2Handler shares the same store contracts and account-linking helpers as OIDCHandler, and to document both handlers’ redirect error query parameters.
Changes:
- Clarify that both
OIDCHandlerandOAuth2Handlerrely onCreateOIDCUserreturningauth.ErrEmailExistsfor race-retry behavior. - Document that
OIDCLinkNonceStoreis required for account linking in both handlers. - Document both
oidc_link_errorandoauth2_link_errorredirect query parameters for interactive link failures.
Show a summary per file
| File | Description |
|---|---|
| docs/auth/store-interfaces.md | Expands store-interface docs to explicitly cover OAuth2Handler (race-retry note, link-nonce store requirement). |
| docs/auth/index.md | Updates sentinel error documentation to mention both handlers’ link-error redirect query parameters. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After the generic
OAuth2Handlerwas added (#203), three places in theauthpackage docs still only mentionedOIDCHandler, even though both handlers share the same underlying store contracts and helpers.Changes
docs/auth/store-interfaces.mdCreateOIDCUserrace-retry note (line 24): creditedOIDCHandleralone, butOAuth2Handleruses the samefindOrCreateUserhelper (inhandler/oauth2_common.go) which has identical retry logic. Updated to say "BothOIDCHandlerandOAuth2Handlerrely on this...".OIDCLinkNonceStoresection (line 260): described the store as required only forOIDCHandleraccount linking.OAuth2Handlerrequires the same store for itsCreateLinkNonce/Linkendpoints. Updated to list both handlers explicitly.docs/auth/index.mdErrOIDCSubjectAlreadyLinkedsentinel (line 31): stated that the interactive link callback redirects withoidc_link_error=Failed+to+link. The sharedhandleLinkCallbackhelper uses a caller-suppliederrorParam, soOAuth2Handlerredirects withoauth2_link_error=Failed+to+linkinstead. Updated to name both query-parameter variants.Verification
All three changes are consistent with the implementation in:
handler/oauth2.go—OAuth2HandlerfieldsLinkNonces auth.OIDCLinkNonceStorehandler/oauth2_common.go—findOrCreateUserwithErrEmailExistsretry;handleLinkCallbackwith configurableerrorParamhandler/oauth2_test.go— tests assertoauth2_link_errorquery parametersNo code changes; documentation only.
Greptile Summary
This PR updates two documentation files to reflect that
OAuth2Handlershares the same store contracts and helpers asOIDCHandler, following the introduction ofOAuth2Handlerin #203.docs/auth/store-interfaces.md: TheCreateOIDCUserrace-retry paragraph is broadened to credit both handlers (both call the sharedfindOrCreateUserhelper), and theOIDCLinkNonceStoresection is updated to list bothOIDCHandlerandOAuth2Handleras consumers of the store, matchingOAuth2Handler.LinkNonces auth.OIDCLinkNonceStore.docs/auth/index.md: TheErrOIDCSubjectAlreadyLinkedtable entry now names bothoidc_link_error(used byOIDCHandler) andoauth2_link_error(used byOAuth2Handler) as the redirect query parameter, consistent with howhandleLinkCallbackis called with a configurableerrorParaminoauth2.go.Confidence Score: 5/5
Documentation-only change; all three updated statements are verified accurate against the live implementation.
Every claim in the updated docs maps directly to code:
findOrCreateUserinoauth2_common.gois called by both handlers and handles theErrEmailExistsretry;OAuth2Handler.LinkNoncesis typedauth.OIDCLinkNonceStore; andhandleLinkCallbackis invoked with"oauth2_link_error"forOAuth2Handlerand a different param forOIDCHandler. No code is touched, so there is no runtime risk.No files require special attention.
Important Files Changed
oidc_link_errorandoauth2_link_errorquery params forErrOIDCSubjectAlreadyLinked; verified accurate againsthandleLinkCallbackusage inoauth2.go.CreateOIDCUserrace-retry note andOIDCLinkNonceStoresection to coverOAuth2Handler; both changes are consistent with the sharedfindOrCreateUserhelper andOAuth2Handler.LinkNoncesfield.Sequence Diagram
sequenceDiagram participant Client participant OAuth2Handler participant OIDCHandler participant findOrCreateUser participant handleLinkCallback participant UserStore Note over OAuth2Handler,OIDCHandler: Shared helpers (oauth2_common.go) Client->>OAuth2Handler: Callback (login flow) OAuth2Handler->>findOrCreateUser: subject, email, name findOrCreateUser->>UserStore: CreateOIDCUser() alt ErrEmailExists (race condition) UserStore-->>findOrCreateUser: ErrEmailExists findOrCreateUser->>UserStore: FindByOIDCSubject / FindByEmail (retry) UserStore-->>findOrCreateUser: existing user end findOrCreateUser-->>OAuth2Handler: "*User" Client->>OAuth2Handler: Callback (link flow) OAuth2Handler->>handleLinkCallback: "errorParam=oauth2_link_error" handleLinkCallback->>UserStore: LinkOIDCSubject() alt failure handleLinkCallback-->>Client: "redirect /?oauth2_link_error=Failed+to+link" else success handleLinkCallback-->>Client: "redirect /?oauth2_linked=true" end Client->>OIDCHandler: Callback (link flow) OIDCHandler->>handleLinkCallback: "errorParam=oidc_link_error" alt failure handleLinkCallback-->>Client: "redirect /?oidc_link_error=Failed+to+link" endReviews (2): Last reviewed commit: "docs(auth): qualify ErrEmailExists refer..." | Re-trigger Greptile