isl-api/helpers/jwtHelpers.go

23 lines
511 B
Go
Raw Permalink Normal View History

package helpers
func JwtHasClaim(claims map[string]interface{}, role string) bool {
zitadelRoles, ok := claims["urn:zitadel:iam:org:project:roles"].(map[string]interface{})
if !ok {
return false
}
_, ok = zitadelRoles[role]
return ok
}
func GetJwtClaim(claims map[string]interface{}, role string) interface{} {
zitadelRoles, ok := claims["urn:zitadel:iam:org:project:roles"].(map[string]interface{})
if !ok {
return nil
}
claim, ok := zitadelRoles[role]
if !ok {
return nil
}
return claim
}