fix: use fixed expiry for asymmetric JWT generation #4752
+1
−1
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.
Summary
Running
supabase status -o envmultiple times produces differentSERVICE_ROLE_KEYvalues on each invocation when using asymmetric signing keys.This breaks workflows where the service role key needs to be stored in a vault or used consistently across multiple command runs.
Problem
When
LoadConfig()is called (which happens on everysupabase statusrun), it regenerates JWT keys.For asymmetric keys, the expiry was set using
time.Now().Add(10 years),causing the JWT payload to have a different expiry timestamp on each generation:
exp: 2036-01-23 19:37:15exp: 2036-01-23 19:37:16(1 second later)Different expiry → Different
JWTpayload → DifferentSERVICE_ROLE_KEYSolution
Use the same fixed expiry constant (
defaultJwtExpiry = 1983812996, expires Nov 2032) that symmetric keys already use.This ensures the JWT payload remains identical across multiple generations.
This aligns asymmetric key behavior with symmetric keys (line 35)
Related