Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package auth provides authentication and authorization utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoToken           = errors.New("no token provided")
	ErrInvalidToken      = errors.New("invalid token")
	ErrTokenExpired      = errors.New("token expired")
	ErrInvalidIssuer     = errors.New("invalid issuer")
	ErrInvalidAudience   = errors.New("invalid audience")
	ErrMissingJWKSURL    = errors.New("missing JWKS URL")
	ErrFailedToFetchJWKS = errors.New("failed to fetch JWKS")
)

Common errors

Functions

This section is empty.

Types

type ClaimsContextKey

type ClaimsContextKey struct{}

ClaimsContextKey is the key used to store claims in the request context.

type JWTValidator

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

JWTValidator validates JWT tokens.

func NewJWTValidator

func NewJWTValidator(ctx context.Context, config JWTValidatorConfig) (*JWTValidator, error)

NewJWTValidator creates a new JWT validator.

func (*JWTValidator) Middleware

func (v *JWTValidator) Middleware(next http.Handler) http.Handler

Middleware creates an HTTP middleware that validates JWT tokens.

func (*JWTValidator) ValidateToken

func (v *JWTValidator) ValidateToken(ctx context.Context, tokenString string) (jwt.MapClaims, error)

ValidateToken validates a JWT token.

type JWTValidatorConfig

type JWTValidatorConfig struct {
	// Issuer is the OIDC issuer URL (e.g., https://accounts.google.com)
	Issuer string

	// Audience is the expected audience for the token
	Audience string

	// JWKSURL is the URL to fetch the JWKS from
	JWKSURL string

	// ClientID is the OIDC client ID
	ClientID string
}

JWTValidatorConfig contains configuration for the JWT validator.

func NewJWTValidatorConfig

func NewJWTValidatorConfig(issuer, audience, jwksURL, clientID string) *JWTValidatorConfig

NewJWTValidatorConfig creates a new JWTValidatorConfig with the provided parameters

Jump to

Keyboard shortcuts

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