auth

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default scopes
	ScopeRead  = "api:read"
	ScopeWrite = "api:write"
	ScopeAdmin = "api:admin"
)

Variables

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

	// ErrNoToken indicates that no bearer token was provided
	ErrNoToken = errors.New("no token provided")
	// 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 FindAuthorizationByToken

func FindAuthorizationByToken(ctx context.Context, token string) (*settings.DialSettings, error)

FindAuthorizationByToken looks for an authorization by the token

func GetBearerToken

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

GetBearerToken extracts the bearer token

func GetClientID

func GetClientID(ctx context.Context, r *http.Request) (string, error)

GetClientID extracts the ClientID from the token

func LookupAuthorization

func LookupAuthorization(ctx context.Context, realm, userid string) (*settings.DialSettings, error)

func RegisterAuthorization added in v0.10.0

func RegisterAuthorization(cfg *settings.DialSettings)

Types

This section is empty.

Jump to

Keyboard shortcuts

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