server

package
v0.0.6-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AllowedJOSEAlgorithms = []jose.SignatureAlgorithm{
		jose.RS256,
		jose.RS384,
		jose.RS512,
		jose.PS256,
		jose.PS384,
		jose.PS512,
		jose.ES256,
		jose.ES384,
		jose.ES512,
		jose.EdDSA,
	}
)

Functions

func ClientID

func ClientID(r *http.Request) string

Generates a rate-limiting client ID by parsing the JWS KID or falling back to the client's IP address

Types

type RateLimiter

type RateLimiter struct {
	MaxRequests int                  // Maximum number of requests allowed
	Interval    time.Duration        // Time interval for rate limit
	Tokens      map[string]int       // Tokens per resource (e.g., per IP or KID)
	LastRequest map[string]time.Time // Track last request time per resource
	// contains filtered or unexported fields
}

RateLimiter holds the configuration for a rate-limiting policy

func NewRateLimiter

func NewRateLimiter(maxRequests int, interval time.Duration) *RateLimiter

NewRateLimiter creates a new rate limiter with the specified maximum requests and interval

func (*RateLimiter) MiddlewareFunc

func (rl *RateLimiter) MiddlewareFunc(resourceKeyFunc func(r *http.Request) string) func(next http.Handler) http.Handler

MiddlewareFunc generates a rate-limiting middleware function using a client IP or JWS KID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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