auth

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminAuthMiddleware

func AdminAuthMiddleware(db sqlx.Ext) (func(http.Handler) http.Handler, error)

AdminAuthMiddleware stores the user context, but always as admin

func JWTMiddleware

func JWTMiddleware(cfg config.Config) (func(http.Handler) http.Handler, error)

JWTMiddleware checks and pulls user information from JWT in Authorization header.

func UserAuthMiddleware

func UserAuthMiddleware(db sqlx.Ext) (func(http.Handler) http.Handler, error)

UserAuthMiddleware stores the user context, but always as admin

Types

type CustomClaimsExample

type CustomClaimsExample struct {
	jwt.StandardClaims
}

func (*CustomClaimsExample) Valid

func (c *CustomClaimsExample) Valid() error

type User

type User struct {
	Name    string
	IsAnon  bool
	IsUser  bool
	IsAdmin bool
}

User defines role access methods.

func ForContext

func ForContext(ctx context.Context) *User

ForContext finds the user from the context. REQUIRES Middleware to have run.

func (*User) HasRole

func (user *User) HasRole(role model.Role) bool

HasRole checks if a User is allowed to use a defined role.

Jump to

Keyboard shortcuts

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