handler

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExchangeHandler

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

ExchangeHandler handles the exchange of API keys for JWT tokens.

func NewExchangeHandler

func NewExchangeHandler(jwtSigner TokenGenerator, store KeyVerifier) *ExchangeHandler

NewExchangeHandler creates a new ExchangeHandler with the provided token generator and key verifier.

func (*ExchangeHandler) Exchange

func (h *ExchangeHandler) Exchange(w http.ResponseWriter, r *http.Request)

Exchange handles HTTP requests to exchange API keys for JWT tokens. It validates the API key and returns a JWT token for the associated organization.

type JWKSHandler

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

JWKSHandler handles serving JSON Web Key Set (JWKS) endpoints.

func NewJWKSHandler

func NewJWKSHandler(jwtSigner PublicKeyProvider) *JWKSHandler

NewJWKSHandler creates a new JWKSHandler with the provided public key provider.

func (*JWKSHandler) ServeJWKS

func (h *JWKSHandler) ServeJWKS(w http.ResponseWriter, r *http.Request)

ServeJWKS handles HTTP requests to serve the JSON Web Key Set (JWKS) containing public keys. It returns the public keys in JWKS format with appropriate caching headers.

type KeyVerifier

type KeyVerifier interface {
	ValidateKey(ctx context.Context, apiKey string) (string, error)
}

KeyVerifier defines the interface for validating API keys and retrieving organization information.

type PublicKeyProvider

type PublicKeyProvider interface {
	GetPublicJWK() jose.JSONWebKey
}

PublicKeyProvider defines the interface for providing public keys in JWK format.

type TokenGenerator

type TokenGenerator interface {
	GenerateToken(org string) (string, error)
}

TokenGenerator defines the interface for generating authentication tokens.

type TokenRequest

type TokenRequest struct {
	APIKey string `json:"api_key"`
}

TokenRequest represents the request payload for token exchange.

type TokenResponse

type TokenResponse struct {
	Token string `json:"token"`
	Error string `json:"error,omitempty"`
}

TokenResponse represents the response payload containing the generated token.

Jump to

Keyboard shortcuts

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