diff --git a/driver/config/provider_fosite.go b/driver/config/provider_fosite.go index 8d319b2d17b..053f0af10ab 100644 --- a/driver/config/provider_fosite.go +++ b/driver/config/provider_fosite.go @@ -93,14 +93,16 @@ func (p *DefaultProvider) GetScopeStrategy(ctx context.Context) fosite.ScopeStra var _ fosite.JWTScopeFieldProvider = (*DefaultProvider)(nil) func (p *DefaultProvider) GetJWTScopeField(ctx context.Context) jwt.JWTScopeFieldEnum { - strategy := strings.ToLower(p.getProvider(ctx).String(KeyJWTScopeClaimStrategy)) - if strategy == "string" { + switch strings.ToLower(p.getProvider(ctx).String(KeyJWTScopeClaimStrategy)) { + case "string": return jwt.JWTScopeFieldString - } - if strategy == "both" { + case "both": return jwt.JWTScopeFieldBoth + case "list": + return jwt.JWTScopeFieldList + default: + return jwt.JWTScopeFieldUnset } - return jwt.JWTScopeFieldList } func (p *DefaultProvider) GetUseLegacyErrorFormat(context.Context) bool { diff --git a/driver/config/provider_test.go b/driver/config/provider_test.go index eb19f8c7d33..b4b42c33dd3 100644 --- a/driver/config/provider_test.go +++ b/driver/config/provider_test.go @@ -474,6 +474,8 @@ func TestJWTScopeClaimStrategy(t *testing.T) { ctx := context.Background() + assert.Equal(t, jwt.JWTScopeFieldList, p.GetJWTScopeField(ctx)) + p.MustSet(ctx, KeyJWTScopeClaimStrategy, "list") assert.Equal(t, jwt.JWTScopeFieldList, p.GetJWTScopeField(ctx)) p.MustSet(ctx, KeyJWTScopeClaimStrategy, "string") assert.Equal(t, jwt.JWTScopeFieldString, p.GetJWTScopeField(ctx))