bouncer/internal/auth/jwt/user.go

33 lines
466 B
Go
Raw Permalink Normal View History

2023-04-24 20:52:12 +02:00
package jwt
import "forge.cadoles.com/cadoles/bouncer/internal/auth"
type Role string
const (
RoleWriter Role = "writer"
RoleReader Role = "reader"
)
func isValidRole(r string) bool {
rr := Role(r)
return rr == RoleWriter || rr == RoleReader
}
type User struct {
subject string
role Role
}
// Subject implements auth.User
func (u *User) Subject() string {
return u.subject
}
func (u *User) Role() Role {
return u.role
}
var _ auth.User = &User{}