tokenauth

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tokenauth provides jwt token authorisation middleware supports HMAC, RSA, ECDSA, RSAPSS algorithms uses github.com/dgrijalva/jwt-go for jwt implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTokenInvalid is returned when the token provided is invalid
	ErrTokenInvalid = errors.New("token invalid")
	// ErrNoToken is returned if no token is supplied in the request.
	ErrNoToken = errors.New("token not found in request")
	// ErrBadSigningMethod is returned if the token sign method in the request
	// does not match the signing method used
	ErrBadSigningMethod = errors.New("unexpected signing method")
)

Functions

func GetHMACKey

func GetHMACKey(jwt.SigningMethod) (interface{}, error)

GetHMACKey gets secret key from env

func GetKeyECDSA

func GetKeyECDSA(jwt.SigningMethod) (interface{}, error)

GetKeyECDSA gets the public.pem file location from env and returns ecdsa.PublicKey

func GetKeyRSA

func GetKeyRSA(jwt.SigningMethod) (interface{}, error)

GetKeyRSA gets the public key file location from env and returns rsa.PublicKey

func GetKeyRSAPSS

func GetKeyRSAPSS(signingMethod jwt.SigningMethod) (interface{}, error)

GetKeyRSAPSS uses GetKeyRSA() since both requires rsa.PublicKey

func New

func New(options Options) buffalo.MiddlewareFunc

New enables jwt token verification if no Sign method is provided, by default uses HMAC

Types

type Options

type Options struct {
	SignMethod jwt.SigningMethod
	GetKey     func(jwt.SigningMethod) (interface{}, error)
}

Options for the JWT middleware

Jump to

Keyboard shortcuts

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