Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBodyTooLarge = errors.New("body too large")
ErrBodyTooLarge is returned when a request body exceeds MaxBodySize.
var MaxBodySize int64 = 10 << 20 // 10MB
MaxBodySize limits how many bytes GetBody will read. Applications may override this value to enforce a custom limit. A value of zero or negative disables the limit entirely.
Functions ¶
func GetBody ¶
GetBody returns the request body bytes while caching the result for subsequent calls. It also resets r.Body so callers can read it again.
func ParseParams ¶
ParseParams decodes the map into the provided struct type while disallowing unknown fields. The returned struct pointer will contain the parsed configuration.
func RegisterIncoming ¶
func RegisterIncoming(p IncomingAuthPlugin)
RegisterIncoming registers an incoming auth plugin.
func RegisterOutgoing ¶
func RegisterOutgoing(p OutgoingAuthPlugin)
RegisterOutgoing registers an outgoing auth plugin.
Types ¶
type Identifier ¶
Identifier is implemented by incoming auth plugins that can derive a caller identifier from the request. The identifier is used by allowlist checks.
type IncomingAuthPlugin ¶
type IncomingAuthPlugin interface {
Name() string
ParseParams(map[string]interface{}) (interface{}, error)
Authenticate(ctx context.Context, r *http.Request, params interface{}) bool
RequiredParams() []string
OptionalParams() []string
}
IncomingAuthPlugin processes authentication from incoming callers. ParseParams should validate and convert the raw parameter map into a plugin-specific configuration struct.
func GetIncoming ¶
func GetIncoming(name string) IncomingAuthPlugin
GetIncoming retrieves an incoming auth plugin by name.
type OutgoingAuthPlugin ¶
type OutgoingAuthPlugin interface {
Name() string
ParseParams(map[string]interface{}) (interface{}, error)
AddAuth(ctx context.Context, r *http.Request, params interface{})
RequiredParams() []string
OptionalParams() []string
}
OutgoingAuthPlugin applies authentication to outbound requests.
func GetOutgoing ¶
func GetOutgoing(name string) OutgoingAuthPlugin
GetOutgoing retrieves an outgoing auth plugin by name.