From ec7fee2a320810a80c3ccb81e1e11406b0b36b4f Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Thu, 27 Jun 2024 13:09:29 +0000 Subject: [PATCH] website/docs: update geoip and asn documentation following field changes (#10265) Co-authored-by: Tana M Berry --- website/docs/policies/expression.mdx | 18 ++++++++++++++---- website/docs/releases/2024/v2024.6.md | 2 -- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/website/docs/policies/expression.mdx b/website/docs/policies/expression.mdx index 66932de0583a..be94ce130263 100644 --- a/website/docs/policies/expression.mdx +++ b/website/docs/policies/expression.mdx @@ -53,16 +53,26 @@ import Objects from "../expressions/_objects.md"; - `request.obj`: A Django Model instance. This is only set if the policy is ran against an object. - `request.context`: A dictionary with dynamic data. This depends on the origin of the execution. -- `geoip`: GeoIP object, see [GeoIP](https://geoip2.readthedocs.io/en/latest/#geoip2.models.City) +- `geoip`: GeoIP dictionary. The following fields are available: + + - `continent`: a two character continent code like `NA` (North America) or `OC` (Oceania). + - `country`: the two character [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) alpha code for the country. + - `lat`: the approximate latitude of the location associated with the IP address. + - `long`: the approximate longitude of the location associated with the IP address. + - `city`: the name of the city. May be empty. ```python - return context["geoip"]["country"]["iso_code"] == "US" + return context["geoip"]["country"] == "US" ``` -- `asn`: ASN object, see [GeoIP](https://geoip2.readthedocs.io/en/latest/#geoip2.models.ASN) +- `asn`: ASN dictionary. The follow fields are available: + + - `asn`: the autonomous system number associated with the IP address. + - `as_org`: the organization associated with the registered autonomous system number for the IP address. + - `network`: the network associated with the record. In particular, this is the largest network where all of the fields except `ip_address` have the same value. ```python - return context["asn"]["autonomous_system_number"] == 64496 + return context["asn"]["asn"] == 64496 ``` - `ak_is_sso_flow`: Boolean which is true if request was initiated by authenticating through an external provider. diff --git a/website/docs/releases/2024/v2024.6.md b/website/docs/releases/2024/v2024.6.md index 06585f1574ac..cda0c12aba83 100644 --- a/website/docs/releases/2024/v2024.6.md +++ b/website/docs/releases/2024/v2024.6.md @@ -27,8 +27,6 @@ With this release, authentik now enforces unique group names. Existing groups wi The `context["geoip"]` and `context["asn"]` objects available in expression policies are now dictionaries. Attributes must now be accessed via dictionary accessors. See [our policy examples](../../policies/expression.mdx) for the updated syntax. -For instance, `context["geoip"].country.iso_code` must now become `context["geoip"]["country"]["iso_code"]`. - ## New features - **Google Workspace Provider** Enterprise Preview