-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Charles-Edouard Brétéché <[email protected]> Co-authored-by: Vishal Choudhary <[email protected]>
- Loading branch information
1 parent
20ca702
commit dd1dc36
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Match conditions | ||
|
||
You can define match conditions if you need fine-grained request filtering. | ||
|
||
Match conditions are **CEL expressions**. All match conditions must evaluate to `true` for the request to be evaluated. | ||
|
||
## Example | ||
|
||
```yaml | ||
apiVersion: envoy.kyverno.io/v1alpha1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: demo | ||
spec: | ||
failurePolicy: Fail | ||
matchConditions: | ||
- name: has-header | ||
expression: has(object.attributes.request.http.headers["x-force-deny"]) | ||
deny: | ||
- response: > | ||
envoy.Denied(403).Response() | ||
``` | ||
In the policy above, the `matchConditions` will be used to deny all requests having the `x-force-deny` header. | ||
|
||
- If an incoming request doesn't have the `x-force-deny` header, then the condition will return `false` and the policy won't apply | ||
- If an incoming request has the `x-force-deny` header, then the condition will return `true` and the `deny` rule will deny the request with status code `403` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters