mirror of
https://forgejo.merr.is/annika/isl-api.git
synced 2025-12-11 12:08:46 -05:00
23 lines
511 B
Go
23 lines
511 B
Go
|
|
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
|
||
|
|
}
|