Documentation ¶
Overview ¶
Package token defines middleware that parses and validates a bearer token and passes it via the request context.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Claims ¶
type Claims struct { jwt.StandardClaims UserID string `json:"uid,omitempty"` }
Claims type.
func (Claims) VerifyAudience ¶
VerifyAudience compares the "aud" claim (if present) against cmp.
func (Claims) VerifyIssuer ¶
VerifyIssuer compares the "iss" claim (if present) against cmp.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware is a token middleware. Use the Handler method to obtain a http.Handler.
func NewMiddleware ¶
func NewMiddleware(o MiddlewareOptions) *Middleware
NewMiddleware returns a new token middleware.
type MiddlewareOptions ¶
type MiddlewareOptions struct { // The value to verify in the "aud" claim (if claim present). Audience string // The value to verify in the "iss" claim (if claim present). Issuer string // This callback function is used to supply the key for verification. The function receives the // parsed, but unverified Token. This allows you to use properties in the Header of the token // (such as `kid`) to identify which key to use. The algorithm specified in the token should be // verified to match the key. KeyFunc jwt.Keyfunc }
MiddlewareOptions control the behaviour of the token middleware.
type Token ¶
type Token struct {
*jwt.Token
}
Token represents a JWT Token.
func FromContext ¶
FromContext returns the Token stored in ctx, if any.
Click to show internal directories.
Click to hide internal directories.