docs: document ErrSessionRevoked handling in FindSessionByRefreshTokenHash and RefreshToken#196
Merged
veverkap merged 2 commits intoMay 3, 2026
Conversation
…nHash and RefreshToken The ErrSessionRevoked sentinel error is now handled in two places: - auth.Middleware: FindSessionByID returning ErrSessionRevoked yields HTTP 401 - handler.RefreshToken: FindSessionByRefreshTokenHash returning ErrSessionRevoked also yields HTTP 401 "invalid or expired refresh token" Update docs/auth/store-interfaces.md to clarify that FindSessionByRefreshTokenHash implementations may also return ErrSessionRevoked (treated identically to ErrNotFound). Update docs/handler/auth.md to surface 'revoked' alongside 'invalid or expired' in the RefreshToken 401 status row. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the authentication documentation to reflect the ErrSessionRevoked behavior added in PR #186, specifically for refresh-token session lookups and the RefreshToken endpoint. It fits into the codebase by keeping the public auth/store contracts and handler docs aligned with the runtime behavior already implemented in handler/auth.go.
Changes:
- Clarifies in
docs/auth/store-interfaces.mdthatFindSessionByRefreshTokenHashmay returnauth.ErrSessionRevoked. - Updates the
AuthHandler.RefreshTokenstatus table entry to mention revoked refresh tokens as a 401 case.
Show a summary per file
| File | Description |
|---|---|
| docs/handler/auth.md | Updates the RefreshToken HTTP 401 condition text in the handler docs. |
| docs/auth/store-interfaces.md | Expands the SessionStore contract notes to document revoked-session handling for refresh-token lookups. |
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.
What changed
PR #186 wired
ErrSessionRevokedinto two additional code paths:auth.Middleware—FindSessionByIDreturningErrSessionRevokednow yieldsHTTP 401 "session expired or revoked"(same asErrNotFound).handler.AuthHandler.RefreshToken—FindSessionByRefreshTokenHashreturningErrSessionRevokednow yieldsHTTP 401 "invalid or expired refresh token"(same asErrNotFound).The middleware docs already covered case 1. Case 2 was not documented.
Documentation updates
docs/auth/store-interfaces.mdThe
SessionStorecontract note previously only mentioned thatFindSessionByIDmay returnErrSessionRevoked. It now also clarifies thatFindSessionByRefreshTokenHashimplementations may returnErrSessionRevoked, and thatRefreshTokentreats it identically toErrNotFound(HTTP 401).docs/handler/auth.mdThe
RefreshTokenHTTP 401 row in the status-code table now reads "Invalid, expired, or revoked refresh token" instead of "Invalid or expired refresh token", accurately reflecting that a revoked session surfaces through this endpoint.Testing
No code changes — documentation only. Verified against
handler/auth.go:250andauth/middleware.go:292.Greptile Summary
Documentation-only PR that backfills the
ErrSessionRevokedcontract forFindSessionByRefreshTokenHashand theRefreshTokenhandler, following the same pattern already established forFindSessionByIDandauth.Middleware. All three changes were verified againsthandler/auth.go:250andauth/types.go— the documented behavior accurately reflects the implementation.Confidence Score: 5/5
Safe to merge — documentation-only change with no code modifications.
All three files contain purely additive documentation updates. The documented behaviour was verified against the source code and is accurate. No logic, types, or tests are modified.
No files require special attention.
Important Files Changed
FindSessionByRefreshTokenHashto documentErrSessionRevokedhandling, consistent with the existingFindSessionByIDcomment pattern and confirmed accurate againsthandler/auth.go:250.ErrSessionRevokedcontract note into two paragraphs, adding an accurate description of howRefreshTokenhandlesErrSessionRevokedfromFindSessionByRefreshTokenHash.RefreshToken401 status-code table entry to include "revoked" as a trigger condition, accurately reflecting theErrSessionRevokedhandling added in PR #186.Sequence Diagram
sequenceDiagram participant Client participant Handler as RefreshToken Handler participant Store as SessionStore Client->>Handler: POST /auth/refresh Handler->>Store: FindSessionByRefreshTokenHash(hash) Store-->>Handler: ErrNotFound OR ErrSessionRevoked Handler-->>Client: 401 Unauthorized Client->>Handler: POST /auth/refresh Handler->>Store: FindSessionByRefreshTokenHash(hash) Store-->>Handler: Session returned Handler->>Store: DeleteSession (consume) Handler-->>Client: 200 OK with new tokensReviews (2): Last reviewed commit: "docs: add ErrSessionRevoked to FindSessi..." | Re-trigger Greptile