jwtvalid

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

README

Module jwt_valid

{
    "pem_keypath": "",
    "secret": "",
    "has_claim": "" "",
}

Description


An HTTP middleware module that validates a JWT using the given query parameter access_token or Authorization header.

It will skip validation if the current HTTP request is an OPTIONS call

Validation can be performed using a given secret OR a public key provided in a PEM formatted file

Field List


pem_keypath

Path to PEM formatted public key file

secret

A text string containing a secret

has_claim

Optional additional validation to ensure given claims contain given values

Expressed as [name] [value] pairs

This field can repeat

Example


jwt_valid {
  secret "MyBigSecret"
  has_claim foo bar
  has_claim hello world
}
Build Instructions

The Makefile is used for all build operations. The file envfile is used for local environment customisations.

Please refer to https://caddyserver.com/docs/extending-caddy for details of configuring your environment and the use of xcaddy.


The current version of Caddy Server specified in the envfile is 2.2.1


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JwtValid

type JwtValid struct {
	KeyPath string            `json:"pemkeypath,omitempty"`
	Secret  string            `json:"secret,omitempty"`
	Claims  map[string]string `json:"hasclaims,omitempty"`
	// contains filtered or unexported fields
}

func (JwtValid) CaddyModule

func (JwtValid) CaddyModule() caddy.ModuleInfo

func (*JwtValid) Provision

func (jtv *JwtValid) Provision(ctx caddy.Context) error

func (JwtValid) ServeHTTP

func (jtv JwtValid) ServeHTTP(resp http.ResponseWriter, req *http.Request, next caddyhttp.Handler) error

type Validator

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

func NewValidator

func NewValidator(pemFilePath string, secret string, hasClaims *map[string]string, logger *zap.Logger) *Validator

func (Validator) Valid

func (v Validator) Valid(token string) (bool, error)

Jump to

Keyboard shortcuts

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