Documentation
¶
Index ¶
- Constants
- Variables
- func CheckAuthorization(ctx context.Context, c echo.Context, scope string) (*settings.DialSettings, error)
- func FindAuthorizationByToken(ctx context.Context, token string) (*settings.DialSettings, error)
- func GetBearerToken(r *http.Request) (string, error)
- func GetClientID(ctx context.Context, r *http.Request) (string, error)
- func LookupAuthorization(ctx context.Context, realm, userid string) (*settings.DialSettings, error)
- func RegisterAuthorization(cfg *settings.DialSettings)
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 ¶
FindAuthorizationByToken looks for an authorization by the token
func GetBearerToken ¶
GetBearerToken extracts the bearer token
func GetClientID ¶
GetClientID extracts the ClientID from the token
func LookupAuthorization ¶
func RegisterAuthorization ¶ added in v0.10.0
func RegisterAuthorization(cfg *settings.DialSettings)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.