Documentation ¶
Index ¶
- Variables
- func CheckPermission(ctx context.Context, perm Permission, bag Bag) error
- func GetRole(ctx context.Context) (*rbac.Role, error)
- func GetUser(ctx context.Context) (guardian.Info, error)
- func Init(q *queries.DBQuerier)
- func IssueToken(ctx context.Context, username string, uid int, roles []string) (string, error)
- func MakeAuthMiddleware(next http.Handler) http.Handler
- func MarshalBag(src interface{}) (string, error)
- func UnmarshalBag(data string, dest interface{}) error
- type Bag
- type ModBag
- type Permission
- type UserBag
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMissingParameters is returned if some required fields on the input message are missing / unset ErrMissingParameters = eris.New("some parameters are missing") // ErrDbIssue is returned if the request could not be processed due to DB issues ErrDbIssue = eris.New("a DB query failed") // ErrAuthCtxMissing is returned if the request didn't contain an authContext ErrAuthCtxMissing = eris.New("auth context missing") )
View Source
var ErrInvalidRole = eris.New("invalid user role")
ErrInvalidRole is returned if the current user has an invalid role
View Source
var ErrInvalidTarget = eris.New("invalid target")
ErrInvalidTarget is returned if the target doesn't follow the expected format
Functions ¶
func CheckPermission ¶
func CheckPermission(ctx context.Context, perm Permission, bag Bag) error
CheckPermission verifies that the currently authenticated user has the given permission
func IssueToken ¶
IssueToken generates a new session token with the associated user
func MakeAuthMiddleware ¶
MakeAuthMiddleware constructs the necessary middleware required for our Auth* API
func MarshalBag ¶
func UnmarshalBag ¶
Types ¶
type Permission ¶
type Permission string
const ( // Mods [takes ModBag] PermViewMod Permission = "ViewMod" PermCreateMod Permission = "CreateMod" PermEditMod Permission = "EditMod" PermDeleteMod Permission = "DeleteMod" // Special perms [takes ModBag] PermEditModTeam Permission = "EditModTeam" PermCreateEngine Permission = "CreateEngine" // Releases [takes ModBag] PermViewRelease Permission = "ViewRelease" PermCreateRelease Permission = "CreateRelease" PermEditRelease Permission = "EditRelease" PermDeleteRelease Permission = "DeleteRelease" // Users [takes UserBag] // Note: CreateUser does *not* apply to the normal registration process PermCreateUser Permission = "CreateUser" PermEditUser Permission = "EditUser" PermDeleteUser Permission = "DeleteUser" )
Click to show internal directories.
Click to hide internal directories.