jwt

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(auth *Auth, options ...Options) error

New constructs a new Auth instance with supplied options.

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

Auth is a middleware that provides jwt based authentication.

func (*Auth) GrabTokenClaims

func (a *Auth) GrabTokenClaims(w http.ResponseWriter, r *http.Request) (ClaimsType, error)

func (*Auth) Handler

func (a *Auth) Handler(h http.Handler) http.Handler

Handler implements the http.HandlerFunc for integration with the standard net/http lib.

func (*Auth) HandlerFuncWithNext

func (a *Auth) HandlerFuncWithNext(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

HandlerFuncWithNext is a special implementation for Negroni, but could be used elsewhere.

func (*Auth) IssueNewTokens

func (a *Auth) IssueNewTokens(w http.ResponseWriter, claims ClaimsType) (err error)

and also modify create refresh and auth token functions!

func (*Auth) NullifyTokenCookies

func (a *Auth) NullifyTokenCookies(w *http.ResponseWriter, r *http.Request)

func (*Auth) Process

func (a *Auth) Process(w http.ResponseWriter, r *http.Request) error

Process runs the actual checks and returns an error if the middleware chain should stop.

func (*Auth) SetCheckTokenIdFunction

func (a *Auth) SetCheckTokenIdFunction(checker TokenIdChecker)

func (*Auth) SetErrorHandler

func (a *Auth) SetErrorHandler(handler http.Handler)

add methods to allow the changing of default functions

func (*Auth) SetRevokeTokenFunction

func (a *Auth) SetRevokeTokenFunction(revoker TokenRevoker)

func (*Auth) SetUnauthorizedHandler

func (a *Auth) SetUnauthorizedHandler(handler http.Handler)

type ClaimsType

type ClaimsType struct {
	// Standard claims are the standard jwt claims from the ietf standard
	// https://tools.ietf.org/html/rfc7519
	jwt.StandardClaims
	Csrf         string
	CustomClaims map[string]interface{}
}

type Options

type Options struct {
	PrivateKeyLocation    string
	PublicKeyLocation     string
	RefreshTokenValidTime time.Duration
	AuthTokenValidTime    time.Duration
	Debug                 bool
	TokenClaims           ClaimsType
}

Options is a struct for specifying configuration options

type TokenIdChecker

type TokenIdChecker func(tokenId string) bool

type TokenRevoker

type TokenRevoker func(tokenId string) error

Jump to

Keyboard shortcuts

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