isl-api/helpers/jwtHelpers.go
Annika Merris b5ea01729b Added JWT Auth
Wrote my own JWT auth middleware, since I could not get the go-chi middleware to accept a JWKS instead of a certificate.
2024-02-10 17:18:22 -05:00

22 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
}