diff --git a/server/env/env.go b/server/env/env.go index e15269d..5905b99 100644 --- a/server/env/env.go +++ b/server/env/env.go @@ -332,7 +332,7 @@ func InitAllEnv() error { envData[constants.EnvKeyJwtRoleClaim] = osJwtRoleClaim if envData[constants.EnvKeyJwtRoleClaim] == "" { - envData[constants.EnvKeyJwtRoleClaim] = "role" + envData[constants.EnvKeyJwtRoleClaim] = "roles" } } if osJwtRoleClaim != "" && envData[constants.EnvKeyJwtRoleClaim] != osJwtRoleClaim { diff --git a/server/resolvers/validate_jwt_token.go b/server/resolvers/validate_jwt_token.go index 8a398a6..7dbb32f 100644 --- a/server/resolvers/validate_jwt_token.go +++ b/server/resolvers/validate_jwt_token.go @@ -77,7 +77,16 @@ func ValidateJwtTokenResolver(ctx context.Context, params model.ValidateJWTToken } } - claimRolesInterface := claims["roles"] + claimKey := "roles" + + if tokenType == constants.TokenTypeIdentityToken { + claimKey, err = memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyJwtRoleClaim) + if err != nil { + claimKey = "roles" + } + } + + claimRolesInterface := claims[claimKey] roleSlice := utils.ConvertInterfaceToSlice(claimRolesInterface) for _, v := range roleSlice { claimRoles = append(claimRoles, v.(string))