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.ClaimsValidator, mode *goflagmode.Flag, ) (*Ed25519Validator, error)
NewEd25519Validator returns a new validator by parsing the given file path as an ED25519 public key
Parameters:
- publicKey: The ED25519 public key in PEM format
- claimsValidator: The token claims validator
- mode: The mode flag to determine if debug mode is enabled
Returns:
- *Ed25519Validator: The ED25519 validator
- error: An error if the public key cannot be parsed or if any parameter is nil
func (Ed25519Validator) GetClaims ¶
func (d Ed25519Validator) GetClaims(rawToken string) ( jwt.MapClaims, error, )
GetClaims parses and validates the given JWT raw token
Parameters:
- rawToken: The raw JWT token string
Returns:
- jwt.MapClaims: The token claims
- error: An error if the token is invalid, if parsing fails, or if the claims are of an unexpected type
func (Ed25519Validator) GetToken ¶
func (d Ed25519Validator) GetToken(rawToken string) (*jwt.Token, error)
GetToken parses the given JWT raw token
Parameters:
- rawToken: The raw JWT token string
Returns:
- *jwt.Token: The parsed JWT token
- error: An error if the token is invalid or if parsing fails
func (Ed25519Validator) ValidateClaims ¶
func (d Ed25519Validator) ValidateClaims( rawToken string, token gojwttoken.Token, ) (jwt.MapClaims, error)
ValidateClaims validates the given token claims based on the given token type and returns the claims if valid
Parameters:
- rawToken: The raw JWT token string
- token: The token type
Returns:
- jwt.MapClaims: The token claims if valid
- error: An error if the token is invalid, if parsing fails, or if the claims are invalid
Click to show internal directories.
Click to hide internal directories.