middleware

package
v0.1.1-0...-f9b01a3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ErrorTokenIsEmpty means that middleware could not find Bearer JWT token in headers
	ErrorTokenIsEmpty = "middleware.token_is_empty"
	//ErrorTokenIsInvalid token validation failed
	ErrorTokenIsInvalid = "middleware.token_is_invalid"
)
View Source
const (
	// AuthorizationHeaderKey is a header name for Bearer token.
	AuthorizationHeaderKey = "Authorization"
	// TokenTypeAccess is an access token type.
	TokenTypeAccess = "access"
	// TokenTypeRefresh is a refresh token type.
	TokenTypeRefresh = "refresh"
	// AccessTokenContextKey context key to store and retreive access token
	AccessTokenContextKey = "identifo.token.access"
	// RefreshTokenContextKey context key to store and retreive refresh token
	RefreshTokenContextKey = "identifo.token.refresh"
)

Variables

This section is empty.

Functions

func TokenFromContext

func TokenFromContext(ctx context.Context) jwt.Token

TokenFromContext returns token from request context.

Types

type Error

type Error string

Error represents error for middleware

func (Error) Description

func (e Error) Description() string

Description returns description for error

type ErrorHandler

type ErrorHandler interface {
	Error(rw http.ResponseWriter, errorType Error, status int, description string)
}

ErrorHandler interface for handling error from middleware rw - readwriter to write error to (JSON, HTML or other error to the client) errorType - error returned from middleware, you can get description by calling errorType.Description() status - http status code

type Handler

type Handler func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Handler is a full copy of negroni.HandlerFunc this is the same http.HandlerFunc, it just has one additional parameter 'next' next is a reference to the next handler in the handler chain

func JWT

JWT returns middleware function you can use to handle JWT token auth

Jump to

Keyboard shortcuts

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