docs: document shared token issuance flow and fix magic-links warning callout#336
Merged
Merged
Conversation
- Add missing '!!! warning "Sessions requires RefreshCookieName"' callout to magic-links.md, matching the style used in auth.md, oauth2.md, oidc.md, and passkeys.md. - Add 'Token issuance flow' section to cookies.md explaining the centralized issueTokens logic extracted in PR #330: session creation, refresh token hashing, JWT minting, and cookie setting. Follows PR #330: Extract shared session/refresh-cookie validation for auth handlers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates handler documentation to reflect the shared, centralized token issuance behavior introduced in PR #330 and to make session/refresh-cookie configuration warnings consistent across handler docs.
Changes:
- Adds a standardized
!!! warning "Sessions requires RefreshCookieName"admonition toMagicLinkHandlerdocs (matching other session-capable handlers). - Documents the shared 5-step token issuance flow (session-enabled vs sessionless) in
docs/handler/cookies.md.
Show a summary per file
| File | Description |
|---|---|
| docs/handler/magic-links.md | Replaces an inline configuration warning with a consistent admonition callout for Sessions + RefreshCookieName validation. |
| docs/handler/cookies.md | Adds a centralized “Token issuance flow” section describing shared issuance steps and how RefreshTokenTTL/DefaultRefreshTokenTTL affect sessions/cookies. |
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: 0
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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.
Follows PR #330 ("Extract shared session/refresh-cookie validation for auth handlers").
Changes
docs/handler/magic-links.mdAdds the
!!! warning "Sessions requires RefreshCookieName"admonition callout that was present in every other session-supporting handler's docs (auth.md,oauth2.md,oidc.md,passkeys.md) but missing frommagic-links.md. The previous inline sentence is replaced with a styled callout for visual consistency.docs/handler/cookies.mdAdds a Token issuance flow section that explains the five-step centralized flow introduced by PR #330. Developers customizing or debugging token issuance now have a single place to understand:
jticlaimSetRefreshCookie/SetAuthCookieare calledRefreshTokenTTL/DefaultRefreshTokenTTLcontrol cookieMax-Ageand session expiryjti, no refresh cookie)Checklist
Add this agentic workflows to your repo
To install this agentic workflow, run
Greptile Summary
This documentation-only PR adds a "Token issuance flow" section to
docs/handler/cookies.mdand adds the missing!!! warning "Sessions requires RefreshCookieName"admonition todocs/handler/magic-links.md. Both changes accurately reflect the implementation inhandler/helpers.go.cookies.md: The five-step token issuance flow description matches theissueTokensfunction exactly — random hex generation viaauth.GenerateRandomHex(32), SHA-256 hashing, session creation,CreateTokenWithSessionwithjti, cookie writes, and theDefaultRefreshTokenTTLfallback.magic-links.md: The inlineRefreshCookieNamerequirement sentence is replaced with a styled warning admonition, bringing it visually in line withauth.md,oauth2.md,oidc.md, andpasskeys.md.Confidence Score: 5/5
Documentation-only change with no behaviour modifications; safe to merge.
Both new documentation sections were verified against the actual implementation in handler/helpers.go and auth/crypto.go. Every step in the token issuance flow description matches the code exactly, the sessionless path description is correct, and the RefreshCookieName warning admonition preserves all information from the removed inline sentence.
No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant H as Handler participant IT as issueTokens() participant S as SessionStore participant J as JWTManager participant W as http.ResponseWriter H->>IT: issueTokens(w, r, userID, sessions, ...) alt Sessions is non-nil IT->>IT: GenerateRandomHex(32) → rawRefresh IT->>IT: HashHighEntropyToken(rawRefresh) → hash IT->>S: CreateSession(ctx, userID, hash, userAgent, ip, now+TTL) S-->>IT: sess (with sess.ID) IT->>J: CreateTokenWithSession(userID, sess.ID) J-->>IT: "accessToken (jti = sess.ID)" IT->>W: "SetRefreshCookie(rawRefresh, refreshCookieName, maxAge=TTL)" IT->>W: SetAuthCookie(accessToken, cookieName) IT-->>H: "accessToken, rawRefresh, ok=true" else Sessions is nil IT->>J: CreateToken(userID) J-->>IT: accessToken (no jti) IT->>W: SetAuthCookie(accessToken, cookieName) IT-->>H: "accessToken, empty, ok=true" endReviews (2): Last reviewed commit: "Update docs/handler/cookies.md" | Re-trigger Greptile