validation

package
v0.59.134 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractBearerToken

func ExtractBearerToken(authHeader string) (string, error)

ExtractBearerToken extracts a Bearer token from an Authorisation header

func GenerateClientID

func GenerateClientID() (string, error)

GenerateClientID generates a unique client ID

func GenerateClientSecret

func GenerateClientSecret() (string, error)

GenerateClientSecret generates a cryptographically secure client secret

func ValidateHTTPSRequest

func ValidateHTTPSRequest(r *http.Request, requireHTTPS bool) error

ValidateHTTPSRequest validates that a request uses HTTPS when required

Types

type JWK

type JWK struct {
	Kty string `json:"kty"` // Key type
	Use string `json:"use"` // Key use
	Kid string `json:"kid"` // Key ID
	Alg string `json:"alg"` // Algorithm
	N   string `json:"n"`   // RSA modulus
	E   string `json:"e"`   // RSA exponent
}

JWK represents a JSON Web Key

type JWKS

type JWKS struct {
	Keys []JWK `json:"keys"`
}

JWKS represents a JSON Web Key Set

type JWKSClient

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

JWKSClient handles fetching and caching JWKS

func NewJWKSClient

func NewJWKSClient(jwksURL string, logger *logrus.Logger) (*JWKSClient, error)

NewJWKSClient creates a new JWKS client

func (*JWKSClient) GetJWKS

func (c *JWKSClient) GetJWKS(ctx context.Context) (*JWKS, error)

GetJWKS returns the full JWKS

func (*JWKSClient) GetKey

func (c *JWKSClient) GetKey(ctx context.Context, keyID string) (any, error)

GetKey retrieves a specific key by ID from the JWKS

func (*JWKSClient) InvalidateCache

func (c *JWKSClient) InvalidateCache()

InvalidateCache invalidates the JWKS cache

type JWTValidator

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

JWTValidator implements token validation for OAuth 2.1 JWT tokens

func NewJWTValidator

func NewJWTValidator(config *types.OAuth2Config, logger *logrus.Logger) (*JWTValidator, error)

NewJWTValidator creates a new JWT token validator

func (*JWTValidator) GetJWKS

func (v *JWTValidator) GetJWKS(ctx context.Context) (any, error)

GetJWKS returns the JWKS for this validator

func (*JWTValidator) ValidateToken

func (v *JWTValidator) ValidateToken(ctx context.Context, tokenString string) (*types.TokenClaims, error)

ValidateToken validates an OAuth 2.1 JWT token

type PKCEValidator

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

PKCEValidator handles PKCE code challenge validation

func NewPKCEValidator

func NewPKCEValidator(logger *logrus.Logger) *PKCEValidator

NewPKCEValidator creates a new PKCE validator

func (*PKCEValidator) GenerateChallenge

func (p *PKCEValidator) GenerateChallenge(method string) (*types.PKCEChallenge, error)

GenerateChallenge generates a PKCE code challenge and verifier

func (*PKCEValidator) ValidateChallenge

func (p *PKCEValidator) ValidateChallenge(challenge, method, verifier string) error

ValidateChallenge validates a PKCE code challenge against a verifier

type WWWAuthenticateBuilder

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

WWWAuthenticateBuilder builds WWW-Authenticate headers for 401 responses

func NewWWWAuthenticateBuilder

func NewWWWAuthenticateBuilder(resourceMetadataURL string) *WWWAuthenticateBuilder

NewWWWAuthenticateBuilder creates a new WWW-Authenticate header builder

func (*WWWAuthenticateBuilder) Build

func (w *WWWAuthenticateBuilder) Build(realm, error, errorDescription string) string

Build builds a WWW-Authenticate header value

Jump to

Keyboard shortcuts

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