Skip to content

Commit

Permalink
chore: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jun 26, 2023
1 parent 1d09e82 commit cffebc2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions driver/config/provider_fosite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions driver/config/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit cffebc2

Please sign in to comment.