Documentation ¶
Overview ¶
Package jwthttp extracts, parses and verifies a token from HTTP requests.
Index ¶
Constants ¶
const HTTPFormInputName = `access_token`
HTTPFormInputName default name for the HTML form field name
const HTTPHeaderAuthorization = `Authorization`
HTTPHeaderAuthorization identifies the bearer token in this header key
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Verification ¶
type Verification struct { csjwt.Verification // FormInputName defines the name of the HTML form input type in which the // token has been stored. If empty, the form the gets ignored. FormInputName string // CookieName defines the name of the cookie where the token has been // stored. If empty, cookie parsing gets ignored. CookieName string // ExtractTokenFn for extracting a token from an HTTP request. The // ExtractToken method should return a token string or an error. // This function can be nil ExtractTokenFn func(*http.Request) (string, error) }
Verification allows to parse and verify a token with custom options.
func NewVerification ¶
func NewVerification(availableSigners ...csjwt.Signer) *Verification
NewVerification creates new verification parser with the default signing method HS256, if availableSigners slice argument is empty. Nil arguments are forbidden.
func (*Verification) ParseFromRequest ¶
func (vf *Verification) ParseFromRequest(dst *csjwt.Token, keyFunc csjwt.Keyfunc, req *http.Request) error
ParseFromRequest same as Parse but extracts the token from a request. First it searches for the token bearer in the header HTTPHeaderAuthorization. If not found the request POST form gets parsed and the FormInputName gets used to lookup the token value.