docs: fix JWT auth recipe API errors from review feedback#81
Merged
Tuntii merged 3 commits intodocs-update-cookbook-v0.1.233-1962074576845807621from Feb 1, 2026
Merged
Conversation
Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update cookbook recipes to match v0.1.233 API
docs: fix JWT auth recipe API errors from review feedback
Feb 1, 2026
… copilot/sub-pr-80
56dcb43
into
docs-update-cookbook-v0.1.233-1962074576845807621
2 checks passed
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects API mismatches and improves clarity in the JWT authentication cookbook recipe, ensuring alignment with the actual rustapi-extras v0.1.233 implementation. The changes address technical inaccuracies identified during review of PR #80.
Changes:
- Updated Claims struct comment to clarify that
expfield is required for JWT expiration validation (which defaults to enabled) - Fixed expiration calculation by properly computing the timestamp using
SystemTime::now()and storing it in a clearly-namedexpirationvariable before assignment - Corrected
JwtLayerinstantiation to use explicit type parameter syntax:JwtLayer::<Claims>::new(secret)
|
|
||
| // Calculate expiration (1 hour from now) | ||
| let exp = SystemTime::now() | ||
| use std::time::{SystemTime, UNIX_EPOCH}; |
There was a problem hiding this comment.
This import statement is redundant. SystemTime and UNIX_EPOCH are already imported at line 47 at the top of the code block. The inline import should be removed.
Suggested change
| use std::time::{SystemTime, UNIX_EPOCH}; |
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.
Corrects API mismatches in JWT authentication cookbook recipe based on code review feedback for PR #80.
JWT Claims Structure
exp: usizefield to Claims struct (JWT validation fails without it due tovalidate_exp: truedefault)expis optionalToken Creation
create_tokensignature: uses 2 parameters(claims, secret), not 3SystemTime::now()in login handlerexpin Claims before callingcreate_tokenFramework Consistency
#[tokio::main]→#[rustapi::main]to match other recipesJwtLayerinstantiation:JwtLayer::<Claims>::new(secret)with type parameter.with_algorithm()call (HS256 is default, use.with_validation()if customization needed)Minor Fixes
All changes align with actual
rustapi-extrasv0.1.233 implementation.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.