Fix service token generation#1731
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes service token generation by filtering out JWT-specific metadata fields before creating new service tokens. The issue (OPS-3197) was likely caused by including exp, iat, and iss fields from an existing principal when generating a new token, which could lead to invalid or expired tokens.
Key changes:
- Destructures and excludes JWT metadata fields (
exp,iat,iss) from the principal before token signing - Preserves all other principal properties in the new service token payload
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Greptile OverviewGreptile SummaryFixed JWT claim double-encoding bug in
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant generateServiceToken
participant extractPrincipal
participant jwtUtils
Client->>generateServiceToken: user JWT
generateServiceToken->>extractPrincipal: decode user JWT
extractPrincipal->>jwtUtils: decodeAndVerify
jwtUtils-->>extractPrincipal: Principal with exp iat iss
extractPrincipal-->>generateServiceToken: return Principal
Note over generateServiceToken: Fix applied here:<br/>Destructure to exclude exp iat iss<br/>before re-signing
generateServiceToken->>jwtUtils: sign clean payload
jwtUtils-->>generateServiceToken: new service JWT
generateServiceToken-->>Client: return service JWT
|



Fixes OPS-3197.