validator

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NilValidatorError            = errors.New("validator cannot be nil")
	InvalidTokenError            = errors.New("invalid token")
	UnexpectedSigningMethodError = errors.New("unexpected signing method")
	InvalidClaimsError           = errors.New("invalid claims")
	NilClaimsError               = errors.New("claims cannot be nil")
	NilClaimsValidatorError      = errors.New("claims validator cannot be nil")
)

Functions

This section is empty.

Types

type ClaimsValidator

type ClaimsValidator interface {
	ValidateClaims(claims *jwt.MapClaims, interception gojwtinterception.Interception) (bool, error)
}

ClaimsValidator interface

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 ClaimsValidator, 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(logger gologger.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