Documentation ¶
Index ¶
- func New(auth *Auth, options ...Options) error
- type Auth
- func (a *Auth) GrabTokenClaims(w http.ResponseWriter, r *http.Request) (ClaimsType, error)
- func (a *Auth) Handler(h http.Handler) http.Handler
- func (a *Auth) HandlerFuncWithNext(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func (a *Auth) IssueNewTokens(w http.ResponseWriter, claims ClaimsType) (err error)
- func (a *Auth) NullifyTokenCookies(w *http.ResponseWriter, r *http.Request)
- func (a *Auth) Process(w http.ResponseWriter, r *http.Request) error
- func (a *Auth) SetCheckTokenIdFunction(checker TokenIdChecker)
- func (a *Auth) SetErrorHandler(handler http.Handler)
- func (a *Auth) SetRevokeTokenFunction(revoker TokenRevoker)
- func (a *Auth) SetUnauthorizedHandler(handler http.Handler)
- type ClaimsType
- type Options
- type TokenIdChecker
- type TokenRevoker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
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 ¶
add methods to allow the changing of default functions
func (*Auth) SetRevokeTokenFunction ¶
func (a *Auth) SetRevokeTokenFunction(revoker TokenRevoker)
func (*Auth) SetUnauthorizedHandler ¶
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 TokenRevoker ¶
Click to show internal directories.
Click to hide internal directories.