Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cookie and port variables fixes #850

Merged
merged 6 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/http/_http_header_templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The source of this data is subject to change. It is currently provided by [MaxMi
| `${req.content_type}` | The media type set in the Content-Type header for this request as a string. |
| `${req.content_type.parameters}` | The parameters set in the Content-Type header as a key value map. |
| `${req.content_type.raw}` | The Content-Type header for this request as a string. |
| `${req.cookies}` | The key value map of HTTP cookie objects provided in the request. |
| `${req.cookies}` | The key value map of HTTP cookie objects included in this request. If there are multiple cookies with the same name, they will be ordered as specified in the Cookie header. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the Set-Cookie header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Cookie since that's the one used by clients in requests, whereas Set-Cookie is used by servers in responses

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup I'm losin it

| `${req.headers}` | The request headers parsed as a map of lower-case names to values. |
| `${req.host}` | The host header field value for this request. |
| `${req.location}` | The location header value of the request. |
Expand All @@ -95,7 +95,7 @@ The source of this data is subject to change. It is currently provided by [MaxMi
| `${req.url.authority}` | The authority portion of the URL. |
| `${req.url.host}` | The hostname portion of the host for this request. |
| `${req.url.path}` | The path for this request including the leading forward slash. |
| `${req.url.port}` | The port portion of the host for this request. |
| `${req.url.port}` | The port portion of the host for this request. This may not be present if the URL does not explicitly specify a port. |
| `${req.url.query}` | The full query string for this request excluding the leading question mark. |
| `${req.url.query_params}` | The request query string parsed as a map of names to values. |
| `${req.url.raw}` | The un-normalized full URL for this request. |
Expand All @@ -111,7 +111,7 @@ The source of this data is subject to change. It is currently provided by [MaxMi
| `${res.content_type}` | The media type set in the Content-Type header for this response as a string. |
| `${res.content_type.parameters}` | The parameters set in the Content-Type header for this response as a key value map. |
| `${res.content_type.raw}` | The Content-Type header for this response as a string. |
| `${res.cookies}` | The key value map of HTTP cookie objects provided in the response. |
| `${res.cookies}` | The key value map of HTTP cookie objects included in this response. If there are multiple cookies with the same name, they will be ordered by path length, with longest path first. |
| `${res.headers}` | The response headers parsed as a map of lower-case names to values. |
| `${res.location}` | The location header value of this response. |
| `${res.status_code}` | The status code of this response. |
Expand Down
36 changes: 18 additions & 18 deletions docs/http/traffic-policy/expressions/macros.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import ConfigExample from "/src/components/ConfigExample.tsx";
CEL provides a set of [predefined macros](https://github.com/google/cel-spec/blob/master/doc/langdef.md#macros) that can
also be used in policy expressions. For convenience, the following custom macros are also supported:

| Name | Return Type | Description |
| -------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`hasReqHeader(string)`](#hasreqheaderstring) | bool | Returns true or false if the provided header key is present on the request. |
| [`getReqHeader(string)`](#getreqheaderstring) | list | Returns a list of header values for the provided key on the request. |
| [`hasQueryParam(string)`](#hasqueryparamstring) | bool | Returns true or false if the specified query parameter key is part of the request URL. |
| [`getQueryParam(string)`](#getqueryparamstring) | list | Returns a list of the query parameter values from the request URL for the specified key. |
| [`hasReqCookie(string)`](#hasreqcookiestring) | bool | Returns true or false if a cookie exists on the request with the specified name. |
| [`getReqCookie(string)`](#getreqcookiestring) | bool | Returns the cookie struct for the specified cookie name, if it exists on the request. |
| [`hasResHeader(string)`](#hasresheaderstring) | bool | Returns true or false if the provided header key is present on the response. |
| [`getResHeader(string)`](#getresheaderstring) | list | Returns a list of header values for the provided key on the response. |
| [`hasResCookie(string)`](#hasrescookiestring) | bool | Returns true or false if a cookie exists on the response with the specified name. |
| [`getResCookie(string)`](#getrescookiestring) | bool | Returns the cookie struct for the specified cookie name, if it exists on the response. |
| [`inCidrRange(ip string, cidr string)`](#incidrrangeip-string-cidr-string) | bool | Returns true or false if the provided IP address falls within the provided CIDR range. Returns false if the provided CIDR range is invalid. |
| [`inCidrRanges(ip string, cidrs list)`](#incidrrangesip-string-cidrs-list) | bool | Returns true or false if the provided IP address falls within any of the provided CIDR ranges. Ignores any provided CIDR ranges that are invalid. |
| Name | Return Type | Description |
| -------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`hasReqHeader(string)`](#hasreqheaderstring) | bool | Returns true or false if the provided header key is present on the request. |
| [`getReqHeader(string)`](#getreqheaderstring) | list | Returns a list of header values for the provided key on the request. |
| [`hasQueryParam(string)`](#hasqueryparamstring) | bool | Returns true or false if the specified query parameter key is part of the request URL. |
| [`getQueryParam(string)`](#getqueryparamstring) | list | Returns a list of the query parameter values from the request URL for the specified key. |
| [`hasReqCookie(string)`](#hasreqcookiestring) | bool | Returns true or false if a cookie exists on the request with the specified name. |
| [`getReqCookie(string)`](#getreqcookiestring) | cookie | Returns the cookie struct for the specified cookie name, if it exists on the request. If there are multiple cookies of the same name, the first from the ordering specified in the Cookie header will be returned. |
| [`hasResHeader(string)`](#hasresheaderstring) | bool | Returns true or false if the provided header key is present on the response. |
| [`getResHeader(string)`](#getresheaderstring) | list | Returns a list of header values for the provided key on the response. |
| [`hasResCookie(string)`](#hasrescookiestring) | bool | Returns true or false if a cookie exists on the response with the specified name. |
| [`getResCookie(string)`](#getrescookiestring) | cookie | Returns the cookie struct for the specified cookie name, if it exists on the response. If there are multiple cookies of the same name, the cookie with the longest path will be returned. |
| [`inCidrRange(ip string, cidr string)`](#incidrrangeip-string-cidr-string) | bool | Returns true or false if the provided IP address falls within the provided CIDR range. Returns false if the provided CIDR range is invalid. |
| [`inCidrRanges(ip string, cidrs list)`](#incidrrangesip-string-cidrs-list) | bool | Returns true or false if the provided IP address falls within any of the provided CIDR ranges. Ignores any provided CIDR ranges that are invalid. |

### `hasReqHeader(string)`

Expand Down Expand Up @@ -74,11 +74,11 @@ Returns true or false if a cookie exists on the request with the specified name.

### `getReqCookie(string)`

Returns the cookie struct for the specified cookie name, if it exists on the request.
Returns the cookie struct for the specified cookie name, if it exists on the request. If there are multiple cookies of the same name, the first from the ordering specified in the Cookie header will be returned.

<ConfigExample
config={{
expressions: ["getReqCookie('session').Secure"],
expressions: ["getReqCookie('session').secure"],
}}
/>

Expand Down Expand Up @@ -116,11 +116,11 @@ Returns true or false if a cookie exists on the response with the specified name

### `getResCookie(string)`

Returns the cookie struct for the specified cookie name, if it exists on the response.
Returns the cookie struct for the specified cookie name, if it exists on the response. If there are multiple cookies of the same name, the cookie with the longest path will be returned.

<ConfigExample
config={{
expressions: ["getResCookie('_device_id').Value == 'mobile-phone-14'"],
expressions: ["getResCookie('_device_id').value == 'mobile-phone-14'"],
}}
/>

Expand Down
Loading