Documentation ¶
Index ¶
- Variables
- func DefaultKeyValuesSanitizerFunc(_ string, _ ...string) []string
- func DefaultPathSanitizerFunc(p string) string
- func PathUUIDs(path string) string
- func Request(r *http.Request, opts ...RequestOption) *http.Request
- type KeyValuesSanitizer
- type KeyValuesSanitizerFunc
- type PathSanitizer
- type PathSanitizerFunc
- type RequestOption
- func OptRequestAddDisallowedHeaders(headers ...string) RequestOption
- func OptRequestAddDisallowedQueryParams(queryParams ...string) RequestOption
- func OptRequestKeyValuesSanitizer(valueSanitizer KeyValuesSanitizer) RequestOption
- func OptRequestPathSanitizer(pathSanitizer PathSanitizer) RequestOption
- func OptRequestSetDisallowedHeaders(headers ...string) RequestOption
- func OptRequestSetDisallowedQueryParams(queryParams ...string) RequestOption
- type RequestSanitizer
Constants ¶
This section is empty.
Variables ¶
var ( DefaultSanitizationDisallowedHeaders = []string{"authorization", "cookie", "set-cookie"} DefaultSanitizationDisallowedQueryParams = []string{"access_token", "client_secret"} )
Default values for disallowed field names Note: the values are compared using `strings.EqualFold` so the casing shouldn't matter
Functions ¶
func DefaultKeyValuesSanitizerFunc ¶ added in v1.20211016.2
DefaultKeyValuesSanitizerFunc is the default value sanitizer.
For any given key's values it will simply return nil, implying that the key was one of the banned keys and we should completely omit the values.
func DefaultPathSanitizerFunc ¶ added in v1.20211016.2
DefaultPathSanitizerFunc is a default implementation of a path sanitizer func that just returns the original path.
Types ¶
type KeyValuesSanitizer ¶ added in v1.20211016.2
KeyValuesSanitizer is a type that can sanitize http header or query key values.
Values are passed from `map[string][]string` typically, hence the `key` and `values...` parameters.
The `SanitizeValue` function should return the modified or sanitized value for each of the input values, for a given key.
type KeyValuesSanitizerFunc ¶ added in v1.20211016.2
KeyValuesSanitizerFunc is a function implementation of ValueSanitizer.
func (KeyValuesSanitizerFunc) SanitizeKeyValues ¶ added in v1.20211016.2
func (vsf KeyValuesSanitizerFunc) SanitizeKeyValues(key string, values ...string) []string
SanitizeKeyValues implements `KeyValuesSanitizer`.
type PathSanitizer ¶ added in v1.20211016.2
PathSanitizer is a type that can sanitize a url path.
type PathSanitizerFunc ¶ added in v1.20211016.2
PathSanitizerFunc implements PathSanitizer.
func (PathSanitizerFunc) SanitizePath ¶ added in v1.20211016.2
func (psf PathSanitizerFunc) SanitizePath(path string) string
SanitizePath implements PathSanitizer.
type RequestOption ¶
type RequestOption func(*RequestSanitizer)
RequestOption is a function that mutates sanitization options.
func OptRequestAddDisallowedHeaders ¶
func OptRequestAddDisallowedHeaders(headers ...string) RequestOption
OptRequestAddDisallowedHeaders adds disallowed request headers, augmenting defaults.
func OptRequestAddDisallowedQueryParams ¶
func OptRequestAddDisallowedQueryParams(queryParams ...string) RequestOption
OptRequestAddDisallowedQueryParams adds disallowed request query params, augmenting defaults.
func OptRequestKeyValuesSanitizer ¶ added in v1.20211016.2
func OptRequestKeyValuesSanitizer(valueSanitizer KeyValuesSanitizer) RequestOption
OptRequestKeyValuesSanitizer sets the request key values sanitizer.
func OptRequestPathSanitizer ¶ added in v1.20211016.2
func OptRequestPathSanitizer(pathSanitizer PathSanitizer) RequestOption
OptRequestPathSanitizer sets the request path sanitizer.
func OptRequestSetDisallowedHeaders ¶
func OptRequestSetDisallowedHeaders(headers ...string) RequestOption
OptRequestSetDisallowedHeaders sets the disallowed request headers, overwriting defaults.
func OptRequestSetDisallowedQueryParams ¶
func OptRequestSetDisallowedQueryParams(queryParams ...string) RequestOption
OptRequestSetDisallowedQueryParams sets the disallowed request query params, overwriting defaults.
type RequestSanitizer ¶ added in v1.20211016.2
type RequestSanitizer struct { DisallowedHeaders []string DisallowedQueryParams []string KeyValuesSanitizer KeyValuesSanitizer PathSanitizer PathSanitizer }
RequestSanitizer are options for sanitization of http requests.
func NewRequestSanitizer ¶ added in v1.20211016.2
func NewRequestSanitizer(opts ...RequestOption) RequestSanitizer
NewRequestSanitizer creates a new request sanitizer.
func (RequestSanitizer) IsHeaderDisallowed ¶ added in v1.20211016.2
func (rs RequestSanitizer) IsHeaderDisallowed(header string) bool
IsHeaderDisallowed returns if a header is in the disallowed list.
func (RequestSanitizer) IsQueryParamDisallowed ¶ added in v1.20211016.2
func (rs RequestSanitizer) IsQueryParamDisallowed(queryParam string) bool
IsQueryParamDisallowed returns if a query param is in the disallowed list.