Documentation ¶
Index ¶
- Variables
- func ContextWithActor(ctx context.Context, user db.AuthenticatedUser, roles []*db.Role) context.Context
- func RequireGlobalAuthorization(actor *Actor, requiredAuthzName roles.Authorization) error
- func RequireRole(actor *Actor, requiredRoleName sqlc.RoleName) error
- func RequireTeamAuthorization(actor *Actor, requiredAuthzName roles.Authorization, targetTeamSlug slug.Slug) error
- type Actor
- type ContextKey
- type ErrMissingAuthorization
- type ErrMissingRole
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotAuthenticated = errors.New("not authenticated")
Functions ¶
func ContextWithActor ¶
func ContextWithActor(ctx context.Context, user db.AuthenticatedUser, roles []*db.Role) context.Context
ContextWithActor Return a context with an actor attached to it.
func RequireGlobalAuthorization ¶
func RequireGlobalAuthorization(actor *Actor, requiredAuthzName roles.Authorization) error
RequireGlobalAuthorization Require an actor to have a specific authorization through a globally assigned role.
func RequireRole ¶
RequireRole Check if an actor has a required role
func RequireTeamAuthorization ¶
func RequireTeamAuthorization(actor *Actor, requiredAuthzName roles.Authorization, targetTeamSlug slug.Slug) error
RequireTeamAuthorization Require an actor to have a specific authorization through a globally assigned or a correctly targeted role.
Types ¶
type Actor ¶
type Actor struct { User db.AuthenticatedUser Roles []*db.Role }
func ActorFromContext ¶
ActorFromContext Get the actor stored in the context. Requires that a middleware has stored an actor in the first place.
func (*Actor) Authenticated ¶
type ContextKey ¶
type ContextKey string
type ErrMissingAuthorization ¶
type ErrMissingAuthorization struct {
// contains filtered or unexported fields
}
func (ErrMissingAuthorization) Authorization ¶
func (e ErrMissingAuthorization) Authorization() string
func (ErrMissingAuthorization) Error ¶
func (e ErrMissingAuthorization) Error() string
type ErrMissingRole ¶
type ErrMissingRole struct {
// contains filtered or unexported fields
}
func (ErrMissingRole) Error ¶
func (e ErrMissingRole) Error() string
func (ErrMissingRole) Role ¶
func (e ErrMissingRole) Role() string
Click to show internal directories.
Click to hide internal directories.