33 lines
473 B
Go
33 lines
473 B
Go
|
package thirdparty
|
||
|
|
||
|
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{}
|