middleware

package
v0.0.0-...-c5e702e Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2018 License: ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxToken contextKey = iota
	CtxUser
	CtxAuthed
	CtxAuthzed
	CtxSession
	CtxJWTCookie
)

Variables

This section is empty.

Functions

func JWTAuthenticator

func JWTAuthenticator(next http.Handler) http.Handler

JWTAuthenticator allows handers to proceed given a validated token identified via jwtauth.FromContext. This should be used after jwtauth.Verify/Verifier.

func JWTParse

func JWTParse(token, key string) (*jwt.Token, error)

JWTParse parses the input token string and validates it with the input key.

func JWTVerify

func JWTVerify(ja *jwtauth.JWTAuth, injectJWTCookie bool, cookieOpts *sessions.Options,
	findTokenFns ...func(r *http.Request) string) func(http.Handler) http.Handler

JWTVerify middleware verifies a JWT from sources defined via the findTokenFns functions. If the jwtauth verification has already been successfully performed for this request, the verifications functions are not run. If injectJWTCookie is true, any located token will be injected as a request cookie, "jwt" so that the session cookie middleware may reuse it. If not injecting a cookie into the request, cookieOpts may be nil.

func NewSignedJWT

func NewSignedJWT(key, user string) (string, jwt.MapClaims, error)

NewSignedJWT generates a new JWT, signs the input key and returns the result along with the claims map and an error value.

func RequestCtxAuthed

func RequestCtxAuthed(r *http.Request) bool

RequestCtxAuthed extracts the CtxAuthed value from the request context.

func RequestCtxAuthzed

func RequestCtxAuthzed(r *http.Request) bool

RequestCtxAuthzed extracts the CtxAuthzed value from the request context.

func RequestCtxJWTSession

func RequestCtxJWTSession(r *http.Request) *sessions.Session

RequestCtxJWTSession extracts the CtxJWTCookie value from the request context.

func RequestCtxSession

func RequestCtxSession(r *http.Request) *sessions.Session

RequestCtxSession extracts the CtxSession value from the request context.

func RequestCtxToken

func RequestCtxToken(r *http.Request) string

RequestCtxToken extracts the CtxToken value from the request context.

func RequestCtxUser

func RequestCtxUser(r *http.Request) string

RequestCtxUser extracts the CtxUser value from the request context.

func UseLog

func UseLog(_log *logrus.Logger)

UseLog sets an external logger for use by this package.

Types

This section is empty.

Jump to

Keyboard shortcuts

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