jwt

package
v1.77.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJwtHandler

func NewJwtHandler(jwtMiddleware *jwtmiddleware.JWTMiddleware, next http.Handler, trustCurrentUser bool) http.Handler

Types

type Jwt

type Jwt struct{}

func NewJwt

func NewJwt() *Jwt

func (Jwt) Handler

func (Jwt) Handler(proxyRoute gobis.ProxyRoute, params interface{}, handler http.Handler) (http.Handler, error)

func (Jwt) Schema

func (Jwt) Schema() interface{}

type JwtConfig

type JwtConfig struct {
	Jwt *JwtOptions `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
}

type JwtHandler

type JwtHandler struct {
	// contains filtered or unexported fields
}

func (JwtHandler) ServeHTTP

func (h JwtHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type JwtOptions

type JwtOptions struct {
	// enable jwt middleware
	Enabled bool `mapstructure:"enabled" json:"enabled" yaml:"enabled"`
	// Algorithm to use to validate the token
	// This is mandatory due to a security issue (see: https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries)
	Alg string `mapstructure:"alg" json:"alg" yaml:"alg"`
	// Secret or private key to verify the jwt
	// This is required
	Secret string `mapstructure:"secret" json:"secret" yaml:"secret"`
	// When set, all requests with the OPTIONS method will use authentication
	// Default: false
	EnableAuthOnOptions bool `mapstructure:"enable_auth_on_options" json:"enable_auth_on_options" yaml:"enable_auth_on_options"`
	// If not empty, it will validate that the jwt contains this audience
	Audience string `mapstructure:"audience" json:"audience" yaml:"audience"`
	// If not empty, it will validate that the jwt contains this issuer
	Issuer string `mapstructure:"issuer" json:"issuer" yaml:"issuer"`
	// Add custom check to verify that the jwt contains those specified claims with specified value
	CustomVerify map[string]string `mapstructure:"custom_verify" json:"custom_verify" yaml:"custom_verify"`
	// Set to true to not verify issued at of token (Useful when you have different time between user and server)
	NotVerifyIssuedAt bool `mapstructure:"not_verify_expire" json:"not_verify_expire" yaml:"not_verify_expire"`
	// Passthrough if a previous middleware already set user context
	// This is helpful when you want add user with basic auth middleware
	TrustCurrentUser bool `mapstructure:"trust_current_user" json:"trust_current_user" yaml:"trust_current_user"`
}

Jump to

Keyboard shortcuts

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