internal

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddResponseRateLimitHeaders

func AddResponseRateLimitHeaders(resp http.ResponseWriter, limit int64, remaining int64, ttl time.Duration)

AddResponseRateLimitHeaders ...

func ExtractBearerToken

func ExtractBearerToken(req http.Request) (*string, error)

ExtractBearerToken ...

func ExtractClaim

func ExtractClaim(claimNames []string) func(claims jwt.MapClaims) (*string, error)

ExtractClaim ...

func ExtractQueryParameter

func ExtractQueryParameter(parameterName string) func(http.Request) (*string, error)

ExtractQueryParameter ...

func ExtractRequestClientIP

func ExtractRequestClientIP(req *http.Request) string

ExtractRequestClientIP ...

Types

type Identifier

type Identifier interface {
	IdentifyRequest(*http.Request) (*string, error)
}

Identifier ...

type IdentifierConfig

type IdentifierConfig struct {
	JwtBearerHeader *IdentifierConfigJwtBearerHeader   `yaml:"jwtBearerHeader"`
	JwtQueryToken   *IdentifierConfigJwtQueryParameter `yaml:"jwtQueryParameter"`
}

IdentifierConfig ...

type IdentifierConfigJwtBearerHeader

type IdentifierConfigJwtBearerHeader struct {
	Algorithm string `yaml:"algorithm"`
	KeyID     string `yaml:"keyId"`
	Verifier  string `yaml:"verifier"`
	Claim     string `yaml:"claim"`
}

IdentifierConfigJwtBearerHeader ...

type IdentifierConfigJwtQueryParameter

type IdentifierConfigJwtQueryParameter struct {
	Algorithm string `yaml:"algorithm"`
	KeyID     string `yaml:"keyId"`
	Verifier  string `yaml:"verifier"`
	Claim     string `yaml:"claim"`
	Name      string `yaml:"name"`
}

IdentifierConfigJwtQueryParameter ...

type JwtIdentifier

type JwtIdentifier struct {
	KeyID             string
	Algorithm         string
	Verifier          string
	TokenExtractor    func(http.Request) (*string, error)
	IdentityExtractor func(claims jwt.MapClaims) (*string, error)
}

JwtIdentifier ...

func (JwtIdentifier) IdentifyRequest

func (id JwtIdentifier) IdentifyRequest(req *http.Request) (*string, error)

IdentifyRequest ...

type RateLimitProxy

type RateLimitProxy struct {
	Config         RateLimitProxyConfig
	RedisClient    redis.Client
	Identifiers    []Identifier
	InnerServeHTTP func(http.ResponseWriter, *http.Request)
}

RateLimitProxy ...

func (*RateLimitProxy) ServeHTTP

func (p *RateLimitProxy) ServeHTTP(wr http.ResponseWriter, req *http.Request)

type RateLimitProxyConfig

type RateLimitProxyConfig struct {
	Redis             RateLimitProxyConfigRedis  `yaml:"redis"`
	Paths             RateLimitProxyConfigPaths  `yaml:"paths"`
	Limits            RateLimitProxyConfigLimits `yaml:"limits"`
	IdentifiersConfig []IdentifierConfig         `yaml:"identifiers"`
}

RateLimitProxyConfig ...

func LoadRateLimitProxyConfig

func LoadRateLimitProxyConfig(bytesRaw []byte) (*RateLimitProxyConfig, *[]Identifier, error)

LoadRateLimitProxyConfig ...

func (RateLimitProxyConfig) Equal

Equal ...

type RateLimitProxyConfigLimits

type RateLimitProxyConfigLimits struct {
	Interval   int64            `yaml:"interval"`
	Anonymous  int64            `yaml:"anonymous"`
	Identified int64            `yaml:"identified"`
	Other      map[string]int64 `yaml:"other"`
}

RateLimitProxyConfigLimits ...

type RateLimitProxyConfigPaths

type RateLimitProxyConfigPaths struct {
	Includes []string `yaml:"includes"`
	Excludes []string `yaml:"excludes"`
}

RateLimitProxyConfigPaths ...

type RateLimitProxyConfigRedis

type RateLimitProxyConfigRedis struct {
	Address   string `yaml:"address"`
	Password  string `yaml:"password"`
	TLS       bool   `yaml:"tls"`
	KeyPrefix string `yaml:"keyPrefix"`
}

RateLimitProxyConfigRedis ...

Jump to

Keyboard shortcuts

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