use jwt claims

This commit is contained in:
Yavolte 2025-06-30 11:25:55 +08:00
parent 29d609ce0a
commit fb585fabe6
1 changed files with 9 additions and 2 deletions

View File

@ -57,9 +57,16 @@ func WithAllow(paths ...string) Option {
}
}
func WithClaims(claims reflect.Type) Option {
func WithClaims(claims any) Option {
return func(o *options) {
o.claims = claims
if tv, ok := claims.(reflect.Type); ok {
o.claims = tv
} else {
o.claims = reflect.TypeOf(claims)
if o.claims.Kind() == reflect.Ptr {
o.claims = o.claims.Elem()
}
}
}
}