auth

package
v0.0.0-...-78a7608 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BetterAuthClient

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

BetterAuthClient fetches OAuth tokens from BetterAuth

func NewBetterAuthClient

func NewBetterAuthClient(authServerURL string) *BetterAuthClient

NewBetterAuthClient creates client to fetch tokens from BetterAuth

func (*BetterAuthClient) GetToken

func (c *BetterAuthClient) GetToken(ctx context.Context, userJWT string, provider Provider) (*Token, error)

GetToken fetches OAuth token from BetterAuth using user's JWT BetterAuth handles storage, refresh, everything

type JWTVerifier

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

JWTVerifier handles JWT token verification with cached JWKS

func NewJWTVerifier

func NewJWTVerifier(jwksURL string) (*JWTVerifier, error)

NewJWTVerifier creates a new JWT verifier with JWKS caching This implementation is optimized for extremely low latency: - JWKS keys are cached with automatic background refresh - No network call on most token verifications - Minimal memory allocations

func (*JWTVerifier) GetCacheStats

func (v *JWTVerifier) GetCacheStats() map[string]interface{}

GetCacheStats returns statistics about the JWKS cache

func (*JWTVerifier) UserFromRequest

func (v *JWTVerifier) UserFromRequest(r *http.Request) (*User, error)

UserFromRequest extracts and validates the JWT token from the request This is the hot path - optimized for minimal allocations and latency

type Provider

type Provider string

Provider represents OAuth providers

const (
	ProviderGoogle    Provider = "google"
	ProviderMicrosoft Provider = "microsoft"
)

type Token

type Token struct {
	AccessToken  string
	RefreshToken string
	Expiry       time.Time
}

Token represents OAuth tokens

type User

type User struct {
	ID    string `json:"id"`
	Email string `json:"email"`
	Name  string `json:"name"`
}

User represents an authenticated user from JWT token

Jump to

Keyboard shortcuts

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