Documentation ¶
Index ¶
Constants ¶
View Source
const ( AuthHeader = "Authorization" ClaimUserId = "uid" ClaimGrant = "grant" )
Variables ¶
View Source
var ( ErrClaimDataType = errors.New("claim is not a string") ErrGrantDataType = errors.New("grant claim is not a string") ErrUserIdDataType = errors.New("user ID claim is not a string") )
View Source
var ( // common errors ErrInvalidBearerToken = errors.New("invalid or missing bearer token") )
View Source
var SetAuthPublicKey = func(pubKey []byte) {
publicAuthKey = pubKey
}
View Source
var SetClaimGrant = func(grant string) {
claimGrant = grant
}
View Source
var SetClaimUserId = func(id string) {
claimUserId = id
}
View Source
var SetErrFunc = func(fn ErrFunc) {
authenticator.SetErrFunc(fn)
}
View Source
var SetKeyFunc = func(fn KeyFunc) {
authenticator.SetKeyFunc(fn)
}
Functions ¶
Types ¶
type ErrFunc ¶
type ErrFunc func(w http.ResponseWriter, err error)
ErrFunc represets a callback function for handling errors when validating requests.
type Middleware ¶
type Middleware interface { // Extract extracts a bearer token from a request. Extract(r *http.Request) (tkn string) // Handle wraps the given handler for validating a request via a JWT. Handle(handler http.HandlerFunc) http.HandlerFunc // SetErrFunc sets the function for handling errors during JWT // validation. SetErrFunc(fn ErrFunc) // SetKeyFunc sets the function for retrieving the JWT's public key. SetKeyFunc(fn KeyFunc) }
Middleware represents an interface to a middleware object.
Click to show internal directories.
Click to hide internal directories.