Docsright arrowEdge Stackright arrowThe FilterPolicy Resource (v1alpha1)

8 min • read

The FilterPolicy Resource (v1alpha1)

The FilterPolicy custom resource works in conjunction with the Filter custom resource to define how and when Ambassador Edge Stack will modify or intercept incoming requests before sending to your upstream Service. Filters define what actions to take on a request, while FilterPolicies define the matching criteria for requests such as the headers, hostname, and path, and supply references to one or more Filters to execute on those requests.


This doc is an overview of all the fields on the FilterPolicy Custom Resource with descriptions of the purpose, type, and default values of those fields. This page is specific to the gateway.getambassador.io/v1alpha1 version of the FilterPolicy resource. For the older getambassador.io/v3alpha1 resource, please see the v3alpha1 FilterPolicy api reference.

FilterPolicy API Reference

FilterPolicy

FieldTypeDescription
rules[]FilterPolicyRuleSet of matching rules that are checked against incoming request to determine which set of Filter's to apply. If no matches are found then the request is allowed through to the upstream service without executing any Filters.

FilterPolicyRule

Appears on: FilterPolicy Configures matching rules that are checked against incoming request to determine which Filter to apply (if any).

FieldTypeDescription
hoststring"glob-string" that matches on the :authority header of the incoming request. If not set it will match on all incoming requests.
pathstring"glob-string" that matches on the request path. If not provided then it will match on all incoming requests.
filterRefs[]FilterReferenceList of references to Filters that will be applied to the incoming request. Filters will be applied to the request in the order they are listed. If no filters are provided then the request will be allowed through to the upstream service without any additional processing. This allows for having one Rule that is overly permissive and then using a single rule to opt-out on certain paths.
precedenceintAllows forcing a precedence ordering on the rules. By default the rules are evaluated in the order they are in the FilterPolicy.spec.rules field. However, multiple FilterPolicy's can be applied to a cluster. To ensure that a specific ordering is enforced then using a precedence is an option.

FilterReference

Appears on: FilterPolicyRule, OAuth2Redirect List of references to Filters that will be applied to the incoming request. Filters will be applied to the request in the order they are listed. If no filters are provided then the request will be allowed through to the upstream service without any additional processing. This allows for having one Rule that is overly permissive and then using a single rule to opt-out on certain paths.

FieldTypeDescription
namestringName that identifies the Filter
namespacestringKubernetes namespace that the Filter resides. It must be a RFC 1123 label. Valid values include: "example", Invalid values include: "example.com" (. is an invalid character). This validation is based off of the corresponding Kubernetes validation.
onDenyEnum ("break","continue")Determines the behavior when a Filter denies the request.
onAllowEnum ("break","continue")Determines the behavior when a Filter denies the request.
ifRequestHeaderHTTPHeaderMatchChecks if exact or regular expression matches a value in a request Header to determine if an individual Filter is executed or not.
argumentsFilterArgumentsStrongly typed input arguments that can be passed into a Filter on per FilterReference level allowing for different behavior on different Rules.

HTTPHeaderMatch

Appears on: FilterPolicyRule, OAuth2Redirect Checks if exact or regular expression matches a value in a request Header to determine if an individual Filter is executed or not.

FieldTypeDescription
typeEnum("Exact","RegularExpression")The semantics of how HTTP header values should be evaluated
namestringName of the header to match. Matching is case insensitive. (See https://tools.ietf.org/html/rfc7230). Valid examples: "Authorization"/"Set-Cookie"/":method".
valuestringValue of HTTP Header to be matched. If type is RegularExpression then this must be a valid regex with length being at least 1.
negateboolAllows the match criteria to be negated or flipped. For example, you can have a regex that checks for any non-empty string which would indicate would translate to if header exists on request then match on it. With negate turned on this would translate to match on any request that doesn't have a header.

FilterArguments

Appears on: FilterPolicyRule Strongly typed input arguments that can be passed into a Filter on per FilterReference level allowing for different behavior on different Rules.

FieldTypeDescription
typeEnum ("jwt"/"oauth2")Identifies the expected type of the arguments that will be passed to the FilterRef. This must match the type of the filterRef and if it doesn't the FilterPolicy rule will be considered invalid and a status condition will be updated to indicate the mismatch.
jwtJWTArgumentsDefines the input arguments that can be set for an JWT Filter on a per FilterPolicy rule level.
oauth2OAuth2ArgumentsDefines the input arguments that can be set for an OAuth2 Filter on a per FilterPolicy rule level.

JWTArguments

Appears on: FilterArguments Defines the input arguments that can be set for an JWT Filter on a per FilterPolicy rule level.

FieldTypeDescription
scope[]stringSet of scopes the JWT will be validated against

OAuth2Arguments

Appears on: FilterArguments Defines the input arguments that can be set for an OAuth2 Filter on a per FilterPolicy rule level.

FieldTypeDescription
scope[]stringSet of scopes the JWT will be validated against
insteadOfRedirectOAuth2RedirectAllows customizing the behavior of the OAuth2 redirect and whether it will redirect the browser or not.
sameSiteEnum("default","none","lax","strict")Set of options for setting the SameSite attribute on a cookie. https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00 for details.

OAuth2Redirect

Appears on: OAuth2Arguments Allows customizing the behavior of the OAuth2 redirect and whether it will redirect the browser or not.

FieldTypeDescription
statusCodeintThe HTTP status code to be used in response. If filterRef is not set then this will default to a 403 forbidden.
ifRequestHeaderHTTPHeaderMatchAllows only applying the InsteadOfRedirect logic when a the header matches.
filterRefs[]FilterReferenceList of references to Filter's that will be applied when an OAuth2 session has expired and the user would like to try a secondary authentication mechanism without redircting to the iDP. Nesting an OAuth2 Filter inside of an OAuth2 Filter is not supported.

FilterPolicyStatus

Automatically managed by the controller to reflect the state of the FilterPolicy

FieldTypeDescription
conditions[]metav1.ConditionDescribes the current condition of the FilterPolicy.
rules[]FilterPolicyRuleStatusDescribes the status for each unique Rule defined in the Spec
rules.indexstringThe zero-based index of the rule within rules with the problem to help with identifying the error
rules.hoststringhost of the rule with the problem to help with identifying the error
rules.pathstringpath of the rule with the problem to help with identifying the error
rules.conditions[]metav1.ConditionDescribes the current condition of a specific rule.