validator

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: GPL-3.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilValidator            = errors.New("validator cannot be nil")
	ErrInvalidToken            = errors.New("invalid token")
	ErrUnexpectedSigningMethod = errors.New("unexpected signing method")
	ErrInvalidClaims           = errors.New("invalid claims")
	ErrNilClaims               = errors.New("claims cannot be nil")
	ErrNilClaimsValidator      = errors.New("claims validator cannot be nil")
)

Functions

This section is empty.

Types

type Ed25519Validator

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

Ed25519Validator handles parsing and validation of JWT tokens with ED25519 public key

func NewEd25519Validator

func NewEd25519Validator(
	publicKey []byte,
	claimsValidator gojwtclaims.Validator,
	mode *goflagmode.Flag,
) (*Ed25519Validator, error)

NewEd25519Validator returns a new validator by parsing the given file path as an ED25519 public key

func (*Ed25519Validator) GetClaims

func (d *Ed25519Validator) GetClaims(rawToken string) (
	*jwt.MapClaims, error,
)

GetClaims parses and validates the given JWT raw token

func (*Ed25519Validator) GetToken

func (d *Ed25519Validator) GetToken(rawToken string) (*jwt.Token, error)

GetToken parses the given JWT raw token

func (*Ed25519Validator) GetValidatedClaims

func (d *Ed25519Validator) GetValidatedClaims(
	rawToken string,
	interception gojwtinterception.Interception,
) (
	*jwt.MapClaims, error,
)

GetValidatedClaims parses, validates and returns the claims of the given JWT raw token

func (*Ed25519Validator) ValidateClaims

func (d *Ed25519Validator) ValidateClaims(
	rawToken string,
	interception gojwtinterception.Interception,
) (*jwt.MapClaims, error)

ValidateClaims validates the given claims

type Logger

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

Logger is the JWT validator logger

func NewLogger

func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error)

NewLogger creates a new JWT validator logger

func (*Logger) MissingTokenClaimsUserId

func (l *Logger) MissingTokenClaimsUserId()

MissingTokenClaimsUserId logs the missing token claims user ID

func (*Logger) ValidatedToken

func (l *Logger) ValidatedToken()

ValidatedToken logs a message when the server validates a token

type Validator

type Validator interface {
	GetToken(rawToken string) (*jwt.Token, error)
	GetClaims(rawToken string) (*jwt.MapClaims, error)
	GetValidatedClaims(
		rawToken string,
		interception gojwtinterception.Interception,
	) (*jwt.MapClaims, error)
}

Validator does parsing and validation of JWT tokens

Jump to

Keyboard shortcuts

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