adapter

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 12 Imported by: 0

README

http adapters

Documentation

Index

Constants

View Source
const JWTTokenKey = "tonto_http_token_key"

JWTTokenKey is used to store token to context

Variables

View Source
var (
	// JWTAlgHS256 represents HMAC SHA256 token signing alg
	JWTAlgHS256 = jwt.SigningMethodHS256

	// JWTAlgHS384 represents HMAC SHA384 token signing alg
	JWTAlgHS384 = jwt.SigningMethodHS384

	// JWTAlgHS512 represents HMAC SHA512 token signing alg
	JWTAlgHS512 = jwt.SigningMethodHS512
)

Functions

func WithCORS

func WithCORS(opts ...CORSOption) http.Adapter

WithCORS creates a new CORS adapter

func WithJWTAuth

func WithJWTAuth(alg JWTAlg, key []byte, callback AuthCallbackFunc) http.Adapter

WithJWTAuth represents jwt authentication adapter It looks for bearer token in Authorization header, and if found tries to validate it against provided alg and key, if successful callback func is called to perform client side auth check.

func WithRequestLogger added in v0.2.6

func WithRequestLogger(l *log.Logger, logRequestBody bool) http.Adapter

WithRequestLogger creates a new request logging adapter

Types

type AuthCallbackFunc

type AuthCallbackFunc func(context.Context, string, map[string]interface{}) error

AuthCallbackFunc represents auth callback that needs to be passed in to JWTAuth middleware. This func is called after token has been successfully verified by adapter so client can do additional business auth check based on the token itself and claims extracted from it Actuall AuthCallbackFunc implementors should return error upon failed auth check or nil on success

type CORSOption

type CORSOption func(*corsCfg)

CORSOption represents cors option

func WithCORSAllowHeaders

func WithCORSAllowHeaders(headers ...string) CORSOption

WithCORSAllowHeaders sets allowed headers

func WithCORSAllowMethods

func WithCORSAllowMethods(methods ...string) CORSOption

WithCORSAllowMethods sets allowed methods

func WithCORSAllowOrigins

func WithCORSAllowOrigins(origins ...string) CORSOption

WithCORSAllowOrigins sets allowed origins

func WithCORSMaxAge

func WithCORSMaxAge(age int) CORSOption

WithCORSMaxAge sets cors max age

type JWTAlg

type JWTAlg *jwt.SigningMethodHMAC

JWTAlg represents token signing alg type

Jump to

Keyboard shortcuts

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