bricks: Index | Files | Directories

package security

import ""


Package Files

authorizer.go helper.go

func ContextWithToken Uses

func ContextWithToken(targetCtx context.Context, token Token) context.Context

ContextWithToken creates a new Context with the token

func GetAuthHeader Uses

func GetAuthHeader(tok Token) string

GetAuthHeader creates the valid value for the authentication header

func GetBearerTokenFromHeader Uses

func GetBearerTokenFromHeader(authHeader string) string

GetBearerTokenFromHeader removes the prefix of authHeader authHeader should be the value of the authorization header field. success: returns the bearer token without the prefix error: return an empty token

type Authorizer Uses

type Authorizer interface {
    // Authorize should authorize a request.
    // Success: returns a context with information of the authorization
    // Error: Handles Errors (logging and creating a response with the error),
    // 		  returns the unchanged context of the request and false
    Authorize(r *http.Request, w http.ResponseWriter) (context.Context, bool)

Authorizer describes the needed functions for authorization, already implemented in oauth2.Authorizer and apikey.Authorizer

type CanAuthorize Uses

type CanAuthorize interface {
    // CanAuthorizeRequest should check if a request contains the needed information to be authorized
    CanAuthorizeRequest(r http.Request) bool

CanAuthorize offers a method to check if an authorizer can authorize a request

type Token Uses

type Token interface {
    // GetValue returns the bearer token
    GetValue() string

Token represents an authentication token.

func GetTokenFromContext Uses

func GetTokenFromContext(ctx context.Context) (Token, bool)

GetTokenFromContext returns the token, if it is stored in the context, and true if the token is present.



Package security imports 3 packages (graph) and is imported by 2 packages. Updated 2020-03-20. Refresh now. Tools for package owners.