Skip to content

Commit

Permalink
feat: keep backwards compatibility through default claims
Browse files Browse the repository at this point in the history
  • Loading branch information
staaldraad committed Jan 19, 2025
1 parent 2f8edec commit e067caa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,15 @@ func (config *GlobalConfiguration) ApplyDefaults() error {
config.JWT.AdminRoles = []string{"service_role", "supabase_admin"}
}

// default to all claims that were / are available at the time of this change
// to ensure backwards compatibility. To exclude all these claims, the value
// of jwt.additional_claims can be set to an invalid claim, such as "none", "empty", "null"
// also allow setting to default claims using the "default" keyword, making it possible to use
// this config as a binary flag "none" == use_mimimal_jwt == true, "default" == use_mimimal_jwt == false
if len(config.JWT.AdditionalClaims) == 0 || (len(config.JWT.AdditionalClaims) == 1 && config.JWT.AdditionalClaims[0] == "default") {
config.JWT.AdditionalClaims = []string{"email", "phone", "app_metadata", "user_metadata", "amr", "is_anonymous"}
}

if config.JWT.Exp == 0 {
config.JWT.Exp = 3600
}
Expand Down

0 comments on commit e067caa

Please sign in to comment.