mirror of
https://forgejo.merr.is/annika/isl-api.git
synced 2025-12-12 15:09:59 -05:00
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.
This commit is contained in:
parent
ac18b94a86
commit
b5ea01729b
12 changed files with 336 additions and 132 deletions
22
helpers/jwtHelpers.go
Normal file
22
helpers/jwtHelpers.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue