authz

package
v0.0.0-...-96f7096 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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

func RequireRole(actor *Actor, requiredRoleName sqlc.RoleName) error

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

func ActorFromContext(ctx context.Context) *Actor

ActorFromContext Get the actor stored in the context. Requires that a middleware has stored an actor in the first place.

func (*Actor) Authenticated

func (u *Actor) Authenticated() bool

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL