jwt

package
v0.0.0-...-0b2e9e9 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package jwt implements a Hook that fails an Announce if the client's request is missing a valid JSON Web Token.

JWTs are validated against the standard claims in RFC7519 along with an extra "infohash" claim that verifies the client has access to the Swarm. RS256 keys are asychronously rotated from a provided JWK Set HTTP endpoint.

Index

Constants

View Source
const Name = "jwt"

Name is the name by which this middleware is registered with Chihaya.

Variables

View Source
var (
	// ErrMissingJWT is returned when a JWT is missing from a request.
	ErrMissingJWT = bittorrent.ClientError("unapproved request: missing jwt")

	// ErrInvalidJWT is returned when a JWT fails to verify.
	ErrInvalidJWT = bittorrent.ClientError("unapproved request: invalid jwt")
)

Functions

func NewHook

func NewHook(cfg Config) (middleware.Hook, error)

NewHook returns an instance of the JWT middleware.

Types

type Config

type Config struct {
	Issuer            string        `yaml:"issuer"`
	Audience          string        `yaml:"audience"`
	JWKSetURL         string        `yaml:"jwk_set_url"`
	JWKUpdateInterval time.Duration `yaml:"jwk_set_update_interval"`
}

Config represents all the values required by this middleware to fetch JWKs and verify JWTs.

func (Config) LogFields

func (cfg Config) LogFields() log.Fields

LogFields implements log.Fielder for a Config.

Jump to

Keyboard shortcuts

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