fix: validating id_token
This commit is contained in:
parent
6ddaf88e3f
commit
70bab70ead
2
server/env/env.go
vendored
2
server/env/env.go
vendored
|
@ -332,7 +332,7 @@ func InitAllEnv() error {
|
||||||
envData[constants.EnvKeyJwtRoleClaim] = osJwtRoleClaim
|
envData[constants.EnvKeyJwtRoleClaim] = osJwtRoleClaim
|
||||||
|
|
||||||
if envData[constants.EnvKeyJwtRoleClaim] == "" {
|
if envData[constants.EnvKeyJwtRoleClaim] == "" {
|
||||||
envData[constants.EnvKeyJwtRoleClaim] = "role"
|
envData[constants.EnvKeyJwtRoleClaim] = "roles"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if osJwtRoleClaim != "" && envData[constants.EnvKeyJwtRoleClaim] != osJwtRoleClaim {
|
if osJwtRoleClaim != "" && envData[constants.EnvKeyJwtRoleClaim] != osJwtRoleClaim {
|
||||||
|
|
|
@ -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)
|
roleSlice := utils.ConvertInterfaceToSlice(claimRolesInterface)
|
||||||
for _, v := range roleSlice {
|
for _, v := range roleSlice {
|
||||||
claimRoles = append(claimRoles, v.(string))
|
claimRoles = append(claimRoles, v.(string))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user