Skip to content

Commit 70bab70

Browse files
committed
fix: validating id_token
1 parent 6ddaf88 commit 70bab70

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

server/env/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func InitAllEnv() error {
332332
envData[constants.EnvKeyJwtRoleClaim] = osJwtRoleClaim
333333

334334
if envData[constants.EnvKeyJwtRoleClaim] == "" {
335-
envData[constants.EnvKeyJwtRoleClaim] = "role"
335+
envData[constants.EnvKeyJwtRoleClaim] = "roles"
336336
}
337337
}
338338
if osJwtRoleClaim != "" && envData[constants.EnvKeyJwtRoleClaim] != osJwtRoleClaim {

server/resolvers/validate_jwt_token.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,16 @@ func ValidateJwtTokenResolver(ctx context.Context, params model.ValidateJWTToken
7777
}
7878
}
7979

80-
claimRolesInterface := claims["roles"]
80+
claimKey := "roles"
81+
82+
if tokenType == constants.TokenTypeIdentityToken {
83+
claimKey, err = memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyJwtRoleClaim)
84+
if err != nil {
85+
claimKey = "roles"
86+
}
87+
}
88+
89+
claimRolesInterface := claims[claimKey]
8190
roleSlice := utils.ConvertInterfaceToSlice(claimRolesInterface)
8291
for _, v := range roleSlice {
8392
claimRoles = append(claimRoles, v.(string))

0 commit comments

Comments
 (0)