fiber_jwt

package module
v0.0.0-...-23ecbba Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 9 Imported by: 0

README

fiber-jwt

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingJWT     = errors.New("missing jwt")
	ErrInvalidPayload = errors.New("cannot map claims")
)

Functions

This section is empty.

Types

type Extractor

type Extractor func(*fiber.Ctx) string

type JWT

type JWT struct {
	// Filter defines an optional function to skip the middleware
	// if a certain criteria is met. Default: nil.
	Filter func(c *fiber.Ctx) bool
	// SuccessHandler is called when the jwt verification process
	// succeeds, so it will call the next handler in the chain.
	SuccessHandler fiber.Handler
	// ErrorHandler is called when an error occurred during
	// the token verification.
	ErrorHandler fiber.ErrorHandler
	// contains filtered or unexported fields
}

func New

func New(options ...JWTOption) JWT

func (*JWT) Serve

func (j *JWT) Serve() fiber.Handler

type JWTOption

type JWTOption interface {
	Option
	// contains filtered or unexported methods
}

func WithAlgorithm

func WithAlgorithm(alg SignatureAlgorithm) JWTOption

func WithNextFunc

func WithNextFunc(f func(*fiber.Ctx) bool) JWTOption

func WithSignKey

func WithSignKey(key any) JWTOption

func WithTokenLookup

func WithTokenLookup(schema string) JWTOption

func WithUserCtxKey

func WithUserCtxKey(key string) JWTOption

func WithVerifyKey

func WithVerifyKey(key any) JWTOption

type Option

type Option = option.Interface

type SignatureAlgorithm

type SignatureAlgorithm = jwa.SignatureAlgorithm
const (
	ES256  SignatureAlgorithm = "ES256"  // ECDSA using P-256 and SHA-256
	ES256K SignatureAlgorithm = "ES256K" // ECDSA using secp256k1 and SHA-256
	ES384  SignatureAlgorithm = "ES384"  // ECDSA using P-384 and SHA-384
	ES512  SignatureAlgorithm = "ES512"  // ECDSA using P-521 and SHA-512
	EdDSA  SignatureAlgorithm = "EdDSA"  // EdDSA signature algorithms
	HS256  SignatureAlgorithm = "HS256"  // HMAC using SHA-256
	HS384  SignatureAlgorithm = "HS384"  // HMAC using SHA-384
	HS512  SignatureAlgorithm = "HS512"  // HMAC using SHA-512
	PS256  SignatureAlgorithm = "PS256"  // RSASSA-PSS using SHA256 and MGF1-SHA256
	PS384  SignatureAlgorithm = "PS384"  // RSASSA-PSS using SHA384 and MGF1-SHA384
	PS512  SignatureAlgorithm = "PS512"  // RSASSA-PSS using SHA512 and MGF1-SHA512
	RS256  SignatureAlgorithm = "RS256"  // RSASSA-PKCS-v1.5 using SHA-256
	RS384  SignatureAlgorithm = "RS384"  // RSASSA-PKCS-v1.5 using SHA-384
	RS512  SignatureAlgorithm = "RS512"  // RSASSA-PKCS-v1.5 using SHA-512
)

Jump to

Keyboard shortcuts

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