Documentation
¶
Index ¶
- func New(auth *Auth, options ...Options) error
- type Auth
- func (a *Auth) GrabTokenClaims(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) error
- func (a *Auth) NullifyTokens(w http.ResponseWriter, r *http.Request) error
- func (a *Auth) Process(w http.ResponseWriter, r *http.Request) *jwtError
- 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(r *http.Request) (ClaimsType, error)
GrabTokenClaims : extract the claims from the request note: we always grab from the authToken
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) error
IssueNewTokens : and also modify create refresh and auth token functions!
func (*Auth) NullifyTokens ¶ added in v0.0.21
NullifyTokens : invalidate tokens note @adam-hanna: what if there are no credentials in the request?
func (*Auth) Process ¶
func (a *Auth) Process(w http.ResponseWriter, r *http.Request) *jwtError
Process runs the actual checks and returns an error if the middleware chain should stop.
func (*Auth) SetCheckTokenIdFunction ¶
func (a *Auth) SetCheckTokenIdFunction(checker TokenIdChecker)
SetCheckTokenIdFunction : set the function which checks token id's
func (*Auth) SetErrorHandler ¶
SetErrorHandler : add methods to allow the changing of default functions
func (*Auth) SetRevokeTokenFunction ¶
func (a *Auth) SetRevokeTokenFunction(revoker TokenRevoker)
SetRevokeTokenFunction : set the function which revokes a token
func (*Auth) SetUnauthorizedHandler ¶
SetUnauthorizedHandler : set the 401 handler
type ClaimsType ¶
type ClaimsType struct { // Standard claims are the standard jwt claims from the ietf standard // https://tools.ietf.org/html/rfc7519 jwtGo.StandardClaims Csrf string CustomClaims map[string]interface{} }
ClaimsType : holds the claims encoded in the jwt
type Options ¶
type Options struct { SigningMethodString string PrivateKeyLocation string PublicKeyLocation string HMACKey []byte VerifyOnlyServer bool BearerTokens bool RefreshTokenValidTime time.Duration AuthTokenValidTime time.Duration Debug bool IsDevEnv bool }
Options is a struct for specifying configuration options
type TokenIdChecker ¶
TokenIdChecker : a type to check tokens
type TokenRevoker ¶
TokenRevoker : a type to revoke tokens
Directories
¶
Path | Synopsis |
---|---|
Godeps
|
|
_workspace/src/github.com/adam-hanna/randomstrings
thanks to @elithrar for the code to create the secret token! source: https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/
|
thanks to @elithrar for the code to create the secret token! source: https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/ |
_workspace/src/github.com/dgrijalva/jwt-go
Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html
|
Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html |