Documentation
¶
Index ¶
Constants ¶
const ( // DefaultRefreshInterval is the default time between refreshes of the JWKS. DefaultRefreshInterval = time.Hour // DefaultRefreshTimeout is the default time to wait for a refresh of the JWKS before cancelling and logging an // error. DefaultRefreshTimeout = 10 * time.Second // DefaultListenAddress is the default address to listen on. DefaultListenAddress = ":8080" // DefaultLogFormat is the default log format. DefaultLogFormat = LogFormatJSON // DefaultRequestMaxBytes is the default maximum number of bytes to read from a request. DefaultRequestMaxBytes = 1 << 20 // 1 MB as defined by http.DefaultMaxHeaderBytes. )
const ( // LogFormatJSON is the JSON log format. LogFormatJSON = "json" // LogFormatHuman is the human-readable log format. LogFormatHuman = "human" )
const ( // ContentTypeJSON is the HTTP header value for Content-Type for JSON. ContentTypeJSON = "application/json" // HeaderContentType is the HTTP header for Content-Type. HeaderContentType = "Content-Type" )
Variables ¶
var ( // ErrClaimCheck is returned when a registered claims check fails. ErrClaimCheck = errors.New("registered claims check failed") // ErrNoConfiguration is returned when no configuration is given. ErrNoConfiguration = errors.New("no configuration provided") )
var ErrInvalidConfig = errors.New("invalid configuration")
ErrInvalidConfig is returned when the configuration is invalid.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
JWKS map[string]JWKSConfig `json:"jwks"`
ListenAddress string `json:"listenAddress"`
LogFormat string `json:"logFormat"`
RequestMaxBytes int64 `json:"requestMaxBytes"`
}
Config contains the configuration for the JWKS client proxy.
func (Config) DefaultsAndValidate ¶
DefaultsAndValidate helps implement the jsontype.Config interface.
type ErrorResponse ¶
type ErrorResponse struct {
Code int `json:"code"`
Meta RequestMeta `json:"meta"`
Msg string `json:"msg"`
}
ErrorResponse is the response for an error.
type HTTPHandler ¶
HTTPHandler is the HTTP handler for the Proxy.
func (HTTPHandler) Validate ¶
func (h HTTPHandler) Validate() http.Handler
Validate creates an HTTP handler for the associated Proxy method.
If more HTTP handlers are added: * Use a middleware for HTTP request metadata method, content type, body limiting, etc.
type JWKSConfig ¶
type JWKSConfig struct {
RefreshInterval *jsontype.JSONType[time.Duration] `json:"refreshInterval"`
RefreshTimeout *jsontype.JSONType[time.Duration] `json:"refreshTimeout"`
}
JWKSConfig contains the configuration for a JWKS.
type Proxy ¶
type Proxy interface {
Validate(ctx context.Context, args ValidateArgs) (ValidateResults, error)
}
Proxy is the interface for the JWKS client proxy.
type RequestMeta ¶
RequestMeta is the metadata for a request.
type ValidateArgs ¶
type ValidateArgs struct {
Aud []string `json:"aud"`
Iss []string `json:"iss"`
Sub []string `json:"sub"`
Token string `json:"token"`
}
ValidateArgs are the arguments for a verification request.
type ValidateRequest ¶
type ValidateRequest struct {
Args ValidateArgs `json:"args"`
}
ValidateRequest is the request for a verification.
type ValidateResponse ¶
type ValidateResponse struct {
Results ValidateResults `json:"results"`
Meta RequestMeta `json:"meta"`
}
ValidateResponse is the response for a verification.
type ValidateResults ¶
type ValidateResults struct {
Success bool `json:"success"`
}
ValidateResults are the results of a verification.