auth

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package auth provides JWT verification with JWKS caching for the LFX MCP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractScopes

func ExtractScopes(token jwt.Token) []string

ExtractScopes extracts scopes from a JWT token. Handles both "scope" (space-separated string) and "scopes" (array) claims.

Types

type JWTVerifier

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

JWTVerifier verifies JWT tokens using cached JWKS from authorization servers.

func NewJWTVerifier

func NewJWTVerifier(cfg JWTVerifierConfig) (*JWTVerifier, error)

NewJWTVerifier creates a new JWT verifier with JWKS caching.

func (*JWTVerifier) VerifyToken

func (v *JWTVerifier) VerifyToken(ctx context.Context, tokenString string) (jwt.Token, error)

VerifyToken verifies a JWT token and returns the parsed token.

type JWTVerifierConfig

type JWTVerifierConfig struct {
	// AuthServers is the list of authorization server URLs (e.g., ["https://example.auth0.com"]).
	// JWKS will be fetched from {authServer}/.well-known/jwks.json for each server.
	AuthServers []string

	// Audience is the expected audience claim (aud) in the JWT.
	Audience string

	// HTTPClient is the HTTP client to use for fetching JWKS.
	// If nil, a default client with 30s timeout will be created.
	HTTPClient *http.Client

	// CacheRefreshInterval is how often to refresh the JWKS cache.
	// If zero, defaults to 15 minutes.
	CacheRefreshInterval time.Duration
}

JWTVerifierConfig holds configuration for JWT verification.

Jump to

Keyboard shortcuts

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