validator

package
v0.0.0-...-6c1d975 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllTokenSources []string

AllTokenSources is the list of token sources.

View Source
var TokenSources = map[string]byte{
	// contains filtered or unexported fields
}

TokenSources is the map containing token source priorities.

Functions

func LoadEncryptionKeys

func LoadEncryptionKeys(config *jwtconfig.CommonTokenConfig) error

LoadEncryptionKeys loads keys for the RSA encryption based on the order determined by rsaSource and rsaConfigSource

Types

type TokenValidator

type TokenValidator struct {
	TokenConfigs         []*jwtconfig.CommonTokenConfig
	AuthorizationHeaders map[string]struct{}
	Cookies              map[string]struct{}
	QueryParameters      map[string]struct{}
	Cache                *jwtcache.TokenCache
	AccessList           []*jwtacl.AccessListEntry
	TokenBackends        []jwtbackends.TokenBackend
	TokenSources         []string
}

TokenValidator validates tokens in http requests.

func NewTokenValidator

func NewTokenValidator() *TokenValidator

NewTokenValidator returns an instance of TokenValidator

func (*TokenValidator) Authorize

func (v *TokenValidator) Authorize(r *http.Request, opts *jwtconfig.TokenValidatorOptions) (claims *jwtclaims.UserClaims, valid bool, err error)

Authorize authorizes HTTP requests based on the presence and the content of the tokens in the request.

func (*TokenValidator) AuthorizeAuthorizationHeader

func (v *TokenValidator) AuthorizeAuthorizationHeader(r *http.Request, opts *jwtconfig.TokenValidatorOptions) (u *jwtclaims.UserClaims, ok bool, err error)

AuthorizeAuthorizationHeader authorizes HTTP requests based on the presence and the content of the tokens in HTTP Authorization header.

func (*TokenValidator) AuthorizeCookies

func (v *TokenValidator) AuthorizeCookies(r *http.Request, opts *jwtconfig.TokenValidatorOptions) (u *jwtclaims.UserClaims, ok bool, err error)

AuthorizeCookies authorizes HTTP requests based on the presence and the content of the tokens in HTTP cookies.

func (*TokenValidator) AuthorizeQueryParameters

func (v *TokenValidator) AuthorizeQueryParameters(r *http.Request, opts *jwtconfig.TokenValidatorOptions) (u *jwtclaims.UserClaims, ok bool, err error)

AuthorizeQueryParameters authorizes HTTP requests based on the presence and the content of the tokens in HTTP query parameters.

func (*TokenValidator) ClearAllSources

func (v *TokenValidator) ClearAllSources()

ClearAllSources clears all sources of token data

func (*TokenValidator) ClearAuthorizationHeaders

func (v *TokenValidator) ClearAuthorizationHeaders()

ClearAuthorizationHeaders clears source HTTP Authorization header.

func (*TokenValidator) ClearCookies

func (v *TokenValidator) ClearCookies()

ClearCookies clears source HTTP cookies.

func (*TokenValidator) ClearQueryParameters

func (v *TokenValidator) ClearQueryParameters()

ClearQueryParameters clears source HTTP query parameters.

func (*TokenValidator) ConfigureTokenBackends

func (v *TokenValidator) ConfigureTokenBackends() error

ConfigureTokenBackends configures available TokenBackend.

func (*TokenValidator) OverwriteTokenName

func (v *TokenValidator) OverwriteTokenName(name string)

OverwriteTokenName sets the name of the token (i.e. <TokenName>=<JWT Token>) this overrites the default token names

func (*TokenValidator) SearchAuthorizationHeader

func (v *TokenValidator) SearchAuthorizationHeader(s string, opts *jwtconfig.TokenValidatorOptions) (string, bool)

SearchAuthorizationHeader searches for tokens in the authorization header of HTTP requests.

func (*TokenValidator) SearchCookies

func (v *TokenValidator) SearchCookies(cookies []*http.Cookie) (string, bool)

SearchCookies searches for tokens in the cookies of HTTP requests.

func (*TokenValidator) SearchQueryValues

func (v *TokenValidator) SearchQueryValues(params url.Values) (string, bool)

SearchQueryValues searches for tokens in the values of query parameters of HTTP requests.

func (*TokenValidator) SetTokenName

func (v *TokenValidator) SetTokenName(name string)

SetTokenName sets the name of the token (i.e. <TokenName>=<JWT Token>)

func (*TokenValidator) ValidateToken

ValidateToken parses a token and returns claims, if valid.

Jump to

Keyboard shortcuts

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