auth

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default API scopes
	ScopeApiRead   = "api:read" // that's the very minimum
	ScopeApiWrite  = "api:write"
	ScopeApiEdit   = "api:edit"
	ScopeApiCreate = "api:create"
	ScopeApiDelete = "api:delete"
	ScopeApiAdmin  = "api:admin"
	// block access
	ScopeApiNoAccess = "api:noaccess"
)

Variables

View Source
var (
	// ErrNotAuthorized indicates that the API caller is not authorized
	ErrNotAuthorized     = errors.New("not authorized")
	ErrAlreadyAuthorized = errors.New("already authorized")

	// ErrAlreadyInitialized indicates that client is already registered
	ErrAlreadyInitialized = errors.New("already initialized")

	// ErrNoToken indicates that no bearer token was provided
	ErrNoToken = errors.New("no token provided")
	// ErrTokenExpired indicates that the token is no longer valid
	ErrTokenExpired = errors.New("token expired")

	// ErrNoScope indicates that no scope was provided
	ErrNoScope = errors.New("no scope provided")
)

Functions

func CheckAuthorization

func CheckAuthorization(ctx context.Context, c echo.Context, scope string) (*settings.DialSettings, error)

CheckAuthorization relies on the presence of a bearer token and validates the matching authorization against a list of requested scopes. If everything checks out, the function returns the authorization or an error otherwise.

func FlushAuthorizations

func FlushAuthorizations(root string)

func GetBearerToken

func GetBearerToken(r *http.Request) (string, error)

func LookupByToken

func LookupByToken(token string) (*settings.DialSettings, error)

func RegisterAuthorization

func RegisterAuthorization(ds *settings.DialSettings) error

func UpdateStore

func UpdateStore(ds *settings.DialSettings) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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