jwthttp

package
v0.0.0-...-202847b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package jwthttp extracts, parses and verifies a token from HTTP requests.

Index

Constants

View Source
const HTTPFormInputName = `access_token`

HTTPFormInputName default name for the HTML form field name

View Source
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL