Parser
microgateway.airlock.com/v1alpha1
Parser contains the configuration for content parsers (default and custom).
apiVersion: microgateway.airlock.com/v1alpha1
kind: Parser
metadata:
name: parser-example
spec:
request:
# Set the content-type to 'application/json' if no content-type header is sent.
defaultContentType: application/json
parsers:
json:
enable: true
mediaTypePattern: .*json.*
form:
enable: true
mediaTypePattern: .*form-urlencoded.*
multipart:
enable: true
mediaTypePattern: .*multipart.*
custom:
rules:
# The POST request to '/company/contact.php' contains a JSON payload
# but has an incorrect content-type header.
# These requests should be treated as JSON.
- requestConditions:
method:
- POST
path:
matcher:
exact: /company/contact.php
action:
parse:
json: {}
# The request to '/support/upload.php' contains a binary payload
# but has an incorrect content-type header 'application/json'.
# These requests should not be parsed (security filters such as deny rules,
# limits, ... should not be applied).
- requestConditions:
path:
matcher:
exact: /support/upload.php
action:
skip: {}
apiVersion: microgateway.airlock.com/v1alpha1
kind: Parser
metadata:
name: default
spec:
request:
parsers:
json:
enable: true
mediaTypePattern: ".*json.*"
form:
enable: true
mediaTypePattern: ".*urlencoded.*"
multipart:
enable: true
mediaTypePattern: ".*multipart.*"
defaultContentType: "application/x-www-form-urlencoded"
custom: {}
Parser
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
metadata |
ObjectMeta | Refer to Kubernetes API documentation for fields of metadata |
yes | ||
spec | object | Specification of the desired parser behavior. | no |
Parser.spec
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
request | object | Request defines the parsing for downstream requests. | no |
Parser.spec.request
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
custom | object | Custom allows configuring additional rules for parser selection. | no | ||
defaultContentType |
string | DefaultContentType specifies the content-type header which should be injected into the request before parser selection if it is not already present and the request has a body. | no | application/x-www-form-urlencoded |
|
parsers | object | Parsers defines the configuration for the available content parsers. | no |
Parser.spec.request.custom
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
rules | object[] | Rules defines a custom set prepended before built-in rules of enabled request parsers. Disable all built-in parsers to overrule them completely. |
no |
Parser.spec.request.custom.rules[]
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
action | object | Action specifies what should happen when a request condition matches. Only one of parse or skip can be set. |
yes | parse{} , skip{} |
|
requestConditions | object | RequestConditions defines additional request properties which must be matched in order for this rule to apply. | yes |
Parser.spec.request.custom.rules[].action
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
parse | object | Parse activates the configured parser. | no | json{} , form{} , multipart{} |
|
skip | object | Skip disables any content parsing | no |
Parser.spec.request.custom.rules[].action.parse
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
form | object | Form activates the Form parser. | no | ||
json | object | JSON activates the JSON parser. | no | ||
multipart | object | Multipart activates the multipart parser. | no |
Parser.spec.request.custom.rules[].requestConditions
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
header | object | Header defines the matching headers of a request. | no | ||
invert |
bool | Invert indicates whether the request condition should be inverted. | no | false |
true , false |
mediaType | object | MediaType defines the matching media type from the content-type header of a request. | no | ||
method |
enum[] | Method defines the matching methods of a request. | no | GET , HEAD , POST , PUT , PATCH , DELETE , CONNECT , OPTIONS , TRACE |
|
path | object | Path defines the matching path of a request. | no | ||
remoteIP | object | RemoteIP defines the matching remote IPs of a request. | no |
Parser.spec.request.custom.rules[].requestConditions.header
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
name | object | Name defines the name of a header. | no | ||
value | object | Value defines the value of a header. | no |
Parser.spec.request.custom.rules[].requestConditions.header.name
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
matcher | object | Matcher defines the way to match a string. In comparison to a normal StringMatcher, a value is always matched ignoring the case and can’t be inverted. | yes | exact{} , prefix{} , suffix{} , regex{} , contains{} |
Parser.spec.request.custom.rules[].requestConditions.header.name.matcher
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
contains |
string | Contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
exact |
string | Exact defines an explicit match on the string specified here. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
prefix |
string | Prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
regex |
string | Regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used. The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
suffix |
string | Suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no |
Parser.spec.request.custom.rules[].requestConditions.header.value
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
matcher | object | yes | exact{} , prefix{} , suffix{} , regex{} , contains{} |
Parser.spec.request.custom.rules[].requestConditions.header.value.matcher
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
contains |
string | Contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
exact |
string | Exact defines an explicit match on the string specified here. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
ignoreCase |
bool | IgnoreCase indicates whether the matching should be case-insensitive. In case of a regex match, the regex gets wrapped with a group (?i:...) . |
no | false |
true , false |
prefix |
string | Prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
regex |
string | Regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used. The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
suffix |
string | Suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no |
Parser.spec.request.custom.rules[].requestConditions.mediaType
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
matcher | object | yes | exact{} , prefix{} , suffix{} , regex{} , contains{} |
Parser.spec.request.custom.rules[].requestConditions.mediaType.matcher
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
contains |
string | Contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
exact |
string | Exact defines an explicit match on the string specified here. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
prefix |
string | Prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
regex |
string | Regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used. The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
suffix |
string | Suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no |
Parser.spec.request.custom.rules[].requestConditions.path
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
matcher | object | yes | exact{} , prefix{} , suffix{} , regex{} , contains{} |
Parser.spec.request.custom.rules[].requestConditions.path.matcher
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
contains |
string | Contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
exact |
string | Exact defines an explicit match on the string specified here. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
ignoreCase |
bool | IgnoreCase indicates whether the matching should be case-insensitive. In case of a regex match, the regex gets wrapped with a group (?i:...) . |
no | false |
true , false |
prefix |
string | Prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
regex |
string | Regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used. The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex. Only one of exact, prefix, suffix, regex or contains can be set. |
no | ||
suffix |
string | Suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead. Only one of exact, prefix, suffix, regex or contains can be set. |
no |
Parser.spec.request.custom.rules[].requestConditions.remoteIP
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
cidrRanges |
string[] | CIDRRanges defines the IPv4 or IPv6 CIDR ranges, e.g. 196.148.3.128/26 or 2001:db8::/28 . |
yes | ||
invert |
bool | Invert indicates whether the match should be inverted. | no | false |
true , false |
Parser.spec.request.parsers
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
form | object | Form defines the configuration for the form parser. | no | ||
json | object | JSON defines the configuration for the JSON parser. | no | ||
multipart | object | Multipart defines the configuration for the multipart parser. | no |
Parser.spec.request.parsers.form
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
enable |
bool | Enable defines whether form payloads are inspected. | no | true |
true , false |
mediaTypePattern |
string | MediaTypePattern is a regex specifying the media types for which the request body should be treated as form arguments. | no | .*urlencoded.* |
Parser.spec.request.parsers.json
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
enable |
bool | Enable defines whether json payloads are inspected. | no | true |
true , false |
mediaTypePattern |
string | MediaTypePattern is a regex specifying the media types for which the request body should be treated as JSON. | no | .*json.* |
Parser.spec.request.parsers.multipart
Field | Type | Description | Required | Default | Allowed Values |
---|---|---|---|---|---|
enable |
bool | Enable defines whether multipart payloads are inspected. | no | true |
true , false |
mediaTypePattern |
string | MediaTypePattern is a regex specifying the media types for which the request body should be treated as a multipart payload. | no | .*multipart.* |