-
Notifications
You must be signed in to change notification settings - Fork 4
fix: account for clock drift in JWT issuance #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughBackdated JWT issued-at values by 60 seconds in Apple client-secret and internal JWT creation to tolerate clock skew; appended new PCR entries to both Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant TokenSvc as Token Service
participant Apple as Apple Sign-in
Client->>TokenSvc: request token
alt creating Apple client-secret
TokenSvc->>TokenSvc: now = Utc::now()
Note over TokenSvc: issued_at = now - 60s\nexp/nbf aligned to issued_at
TokenSvc->>Apple: sign JWT (header, claims, signature)
Apple-->>TokenSvc: signed client-secret
else creating internal JWT
TokenSvc->>TokenSvc: now = Utc::now()
Note over TokenSvc: issued_at = now - 60s\nexp/nbf aligned to issued_at
TokenSvc->>TokenSvc: sign JWT
end
TokenSvc-->>Client: return token
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (5)
Comment |
Greptile OverviewGreptile SummaryThis PR mitigates clock drift issues in JWT token generation by backdating the issued-at timestamp by 60 seconds. This prevents verification failures when the issuing server's clock is slightly ahead of the validating server. Key changes:
The 60-second buffer provides reasonable tolerance for typical clock skew scenarios between distributed servers. Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant Server
participant JWT as JWT Generation
participant Validator as JWT Validation
Note over Server,JWT: Token Generation with Clock Drift Fix
Client->>Server: Request authentication
Server->>JWT: Generate token (NewToken::new)
JWT->>JWT: now = Utc::now()
JWT->>JWT: iat = now - 60 seconds
JWT->>JWT: exp = iat + duration
JWT->>JWT: nbf = iat
JWT->>Server: Return signed JWT
Server->>Client: Return JWT token
Note over Client,Validator: Token Validation
Client->>Server: Request with JWT (Bearer token)
Server->>Validator: Validate token
Validator->>Validator: Check expiration (exp)
Validator->>Validator: Check audience (aud)
Validator->>Validator: Verify signature
Validator->>Server: Return claims
Server->>Client: Authorized response
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, no comments
|
@claude what did |
|
Claude finished @AnthonyRonning's task —— View job Analysis of
|
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
d994651 to
ec4f45c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, no comments
Backdates JWT issuance time (iat) by 60 seconds to prevent verification failures due to clock drift between servers. Ensures 'exp' and 'nbf' are calculated relative to the adjusted 'iat'.
Summary by CodeRabbit
Bug Fixes
Data
✏️ Tip: You can customize this high-level summary in your review settings.