Merge branch 'main' into dev

* main:
  website/docs: Fix nginx proxy_pass directive documentation (#10181)
  website/docs: Remove hyphen in read replica in Release Notes (#10178)
  core: rework base for SkipObject exception to better support control flow exceptions (#10186)
  web: bump glob from 10.4.1 to 10.4.2 in /web (#10163)
  core: bump google-api-python-client from 2.133.0 to 2.134.0 (#10183)
  web: bump @sentry/browser from 8.9.2 to 8.10.0 in /web in the sentry group (#10185)
  website/docs: update template reference (#10166)
This commit is contained in:
Ken Sternberg
2024-06-20 08:27:21 -07:00
17 changed files with 109 additions and 84 deletions

View File

@ -1,5 +1,6 @@
"""authentik core exceptions"""
from authentik.lib.expression.exceptions import ControlFlowException
from authentik.lib.sentry import SentryIgnoredException
@ -12,11 +13,7 @@ class PropertyMappingExpressionException(SentryIgnoredException):
self.mapping = mapping
class SkipObjectException(PropertyMappingExpressionException):
class SkipObjectException(ControlFlowException):
"""Exception which can be raised in a property mapping to skip syncing an object.
Only applies to Property mappings which sync objects, and not on mappings which transitively
apply to a single user"""
def __init__(self) -> None:
# For this class only, both of these are set by the function evaluating the property mapping
super().__init__(exc=None, mapping=None)

View File

@ -26,6 +26,7 @@ from authentik.blueprints.models import ManagedModel
from authentik.core.expression.exceptions import PropertyMappingExpressionException
from authentik.core.types import UILoginButton, UserSettingSerializer
from authentik.lib.avatars import get_avatar
from authentik.lib.expression.exceptions import ControlFlowException
from authentik.lib.generators import generate_id
from authentik.lib.models import (
CreatedUpdatedModel,
@ -783,6 +784,8 @@ class PropertyMapping(SerializerModel, ManagedModel):
evaluator = PropertyMappingEvaluator(self, user, request, **kwargs)
try:
return evaluator.evaluate(self.expression)
except ControlFlowException as exc:
raise exc
except Exception as exc:
raise PropertyMappingExpressionException(self, exc) from exc

View File

@ -3,7 +3,10 @@
from django.test import RequestFactory, TestCase
from guardian.shortcuts import get_anonymous_user
from authentik.core.expression.exceptions import PropertyMappingExpressionException
from authentik.core.expression.exceptions import (
PropertyMappingExpressionException,
SkipObjectException,
)
from authentik.core.models import PropertyMapping
from authentik.core.tests.utils import create_test_admin_user
from authentik.events.models import Event, EventAction
@ -42,6 +45,17 @@ class TestPropertyMappings(TestCase):
self.assertTrue(events.exists())
self.assertEqual(len(events), 1)
def test_expression_skip(self):
"""Test expression error"""
expr = "raise SkipObject"
mapping = PropertyMapping.objects.create(name=generate_id(), expression=expr)
with self.assertRaises(SkipObjectException):
mapping.evaluate(None, None)
events = Event.objects.filter(
action=EventAction.PROPERTY_MAPPING_EXCEPTION, context__expression=expr
)
self.assertFalse(events.exists())
def test_expression_error_extended(self):
"""Test expression error (with user and http request"""
expr = "return aaa"

View File

@ -19,6 +19,7 @@ from structlog.stdlib import get_logger
from authentik.core.models import User
from authentik.events.models import Event
from authentik.lib.expression.exceptions import ControlFlowException
from authentik.lib.utils.http import get_http_session
from authentik.policies.models import Policy, PolicyBinding
from authentik.policies.process import PolicyProcess
@ -216,7 +217,8 @@ class BaseEvaluator:
# so the user only sees information relevant to them
# and none of our surrounding error handling
exc.__traceback__ = exc.__traceback__.tb_next
self.handle_error(exc, expression_source)
if not isinstance(exc, ControlFlowException):
self.handle_error(exc, expression_source)
raise exc
return result

View File

@ -0,0 +1,6 @@
from authentik.lib.sentry import SentryIgnoredException
class ControlFlowException(SentryIgnoredException):
"""Exceptions used to control the flow from exceptions, not reported as a warning/
error in logs"""

View File

@ -6,9 +6,9 @@ from django.http import HttpRequest
from authentik.core.expression.evaluator import PropertyMappingEvaluator
from authentik.core.expression.exceptions import (
PropertyMappingExpressionException,
SkipObjectException,
)
from authentik.core.models import PropertyMapping, User
from authentik.lib.expression.exceptions import ControlFlowException
class PropertyMappingManager:
@ -60,11 +60,7 @@ class PropertyMappingManager:
mapping.set_context(user, request, **kwargs)
try:
value = mapping.evaluate(mapping.model.expression)
except SkipObjectException as exc:
exc.exc = exc
exc.mapping = mapping
raise exc from exc
except PropertyMappingExpressionException as exc:
except (PropertyMappingExpressionException, ControlFlowException) as exc:
raise exc from exc
except Exception as exc:
raise PropertyMappingExpressionException(exc, mapping.model) from exc

View File

@ -9,9 +9,9 @@ from structlog.stdlib import get_logger
from authentik.core.expression.exceptions import (
PropertyMappingExpressionException,
SkipObjectException,
)
from authentik.events.models import Event, EventAction
from authentik.lib.expression.exceptions import ControlFlowException
from authentik.lib.sync.mapper import PropertyMappingManager
from authentik.lib.sync.outgoing.exceptions import NotFoundSyncException, StopSync
from authentik.lib.utils.errors import exception_to_string
@ -92,7 +92,7 @@ class BaseOutgoingSyncClient[
eval_kwargs.setdefault("user", None)
for value in self.mapper.iter_eval(**eval_kwargs):
always_merger.merge(raw_final_object, value)
except SkipObjectException as exc:
except ControlFlowException as exc:
raise exc from exc
except PropertyMappingExpressionException as exc:
# Value error can be raised when assigning invalid data to an attribute

6
poetry.lock generated
View File

@ -1707,13 +1707,13 @@ grpcio-gcp = ["grpcio-gcp (>=0.2.2,<1.0.dev0)"]
[[package]]
name = "google-api-python-client"
version = "2.133.0"
version = "2.134.0"
description = "Google API Client Library for Python"
optional = false
python-versions = ">=3.7"
files = [
{file = "google-api-python-client-2.133.0.tar.gz", hash = "sha256:293092905b66a046d3187a99ac454e12b00cc2c70444f26eb2f1f9c1a82720b4"},
{file = "google_api_python_client-2.133.0-py2.py3-none-any.whl", hash = "sha256:396fe676ea0dfed066654dcf9f8dea77a1342f9d9bb23bb88e45b7b81e773926"},
{file = "google-api-python-client-2.134.0.tar.gz", hash = "sha256:4a8f0bea651a212997cc83c0f271fc86f80ef93d1cee9d84de7dfaeef2a858b6"},
{file = "google_api_python_client-2.134.0-py2.py3-none-any.whl", hash = "sha256:ba05d60f6239990b7994f6328f17bb154c602d31860fb553016dc9f8ce886945"},
]
[package.dependencies]

113
web/package-lock.json generated
View File

@ -25,7 +25,7 @@
"@open-wc/lit-helpers": "^0.7.0",
"@patternfly/elements": "^3.0.2",
"@patternfly/patternfly": "^4.224.2",
"@sentry/browser": "^8.9.2",
"@sentry/browser": "^8.10.0",
"@webcomponents/webcomponentsjs": "^2.8.0",
"base64-js": "^1.5.1",
"chart.js": "^4.4.3",
@ -87,7 +87,7 @@
"eslint-plugin-sonarjs": "^0.25.1",
"eslint-plugin-storybook": "^0.8.0",
"github-slugger": "^2.0.0",
"glob": "^10.4.1",
"glob": "^10.4.2",
"lit-analyzer": "^2.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.2",
@ -4630,102 +4630,102 @@
"peer": true
},
"node_modules/@sentry-internal/browser-utils": {
"version": "8.9.2",
"resolved": "https://registry.npmjs.org/@sentry-internal/browser-utils/-/browser-utils-8.9.2.tgz",
"integrity": "sha512-2A0A6TnfzFDvYCRWS9My3t+JKG6KlslhyaN35BTiOTlYDauEekyJP7BFFyeTJXCHm2BQgI8aRZhBKm+oR9QuYw==",
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/@sentry-internal/browser-utils/-/browser-utils-8.10.0.tgz",
"integrity": "sha512-Hdqv8KfQDCj7H92ft2walDwCiyaTxgegHnR4ZtCI8NQR0hqdU/PzIKashTwc+Ho6OAQtdy/HNqhcHEznuBNW3A==",
"dependencies": {
"@sentry/core": "8.9.2",
"@sentry/types": "8.9.2",
"@sentry/utils": "8.9.2"
"@sentry/core": "8.10.0",
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0"
},
"engines": {
"node": ">=14.18"
}
},
"node_modules/@sentry-internal/feedback": {
"version": "8.9.2",
"resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-8.9.2.tgz",
"integrity": "sha512-v04Q+08ohwautwmiDfK5hI+nFW2B/IYhBz7pZM9x1srkwmNA69XOFyo5u34TeVHhYOPbMM2Ubs0uNEcSWHgbbQ==",
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-8.10.0.tgz",
"integrity": "sha512-pzc4s5X6wvY0BMQBFAMObQBjRKiKzoF2APD5H5eBcxkX8deIykjm8VC8mgpVpxYm6mfjytvgpZyPpZ6KgpRt9Q==",
"dependencies": {
"@sentry/core": "8.9.2",
"@sentry/types": "8.9.2",
"@sentry/utils": "8.9.2"
"@sentry/core": "8.10.0",
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0"
},
"engines": {
"node": ">=14.18"
}
},
"node_modules/@sentry-internal/replay": {
"version": "8.9.2",
"resolved": "https://registry.npmjs.org/@sentry-internal/replay/-/replay-8.9.2.tgz",
"integrity": "sha512-YPnrnXJd6mJpJspJ8pI8hd1KTMOxw+BARP5twiDwXlij1RTotwnNoX9UGaSm+ZPTexPD++6Zyp6xQf4vKKP3yg==",
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/@sentry-internal/replay/-/replay-8.10.0.tgz",
"integrity": "sha512-MISdD0Q0sVcQELHbYSH5SuKHlrI8RFvmU6aNcjWEoKxhd4Vzr126h98naVPoo7WOOI0e7Fd0Lrn/59wNI4AJxQ==",
"dependencies": {
"@sentry-internal/browser-utils": "8.9.2",
"@sentry/core": "8.9.2",
"@sentry/types": "8.9.2",
"@sentry/utils": "8.9.2"
"@sentry-internal/browser-utils": "8.10.0",
"@sentry/core": "8.10.0",
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0"
},
"engines": {
"node": ">=14.18"
}
},
"node_modules/@sentry-internal/replay-canvas": {
"version": "8.9.2",
"resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-8.9.2.tgz",
"integrity": "sha512-vu9TssSjO+XbZjnoyYxMrBI4KgXG+zyqw3ThfPqG6o7O0BGa54fFwtZiMdGq/BHz017FuNiEz4fgtzuDd4gZJQ==",
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-8.10.0.tgz",
"integrity": "sha512-M4yM8ZqtsW1wER7jNpGq019jmhn/RkcmdIyWksRpBSvRppZRf0yR9dbVhdO/oBL8DB3fDTbv8Qtd/oXlkj/i+Q==",
"dependencies": {
"@sentry-internal/replay": "8.9.2",
"@sentry/core": "8.9.2",
"@sentry/types": "8.9.2",
"@sentry/utils": "8.9.2"
"@sentry-internal/replay": "8.10.0",
"@sentry/core": "8.10.0",
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0"
},
"engines": {
"node": ">=14.18"
}
},
"node_modules/@sentry/browser": {
"version": "8.9.2",
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-8.9.2.tgz",
"integrity": "sha512-jI5XY4j8Sa+YteokI+4SW+A/ErZxPDnspjvV3dm5pIPWvEFhvDyXWZSepqaoqwo3L7fdkRMzXY8Bi4T7qDVMWg==",
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-8.10.0.tgz",
"integrity": "sha512-6yGax6vUNV28cANMJCTrLFrGTvvgC0h4k+lzjrgstCf1k+CNQmodXDyWcRzbL4im5DTH4jF74ZAYpqrptloxJw==",
"dependencies": {
"@sentry-internal/browser-utils": "8.9.2",
"@sentry-internal/feedback": "8.9.2",
"@sentry-internal/replay": "8.9.2",
"@sentry-internal/replay-canvas": "8.9.2",
"@sentry/core": "8.9.2",
"@sentry/types": "8.9.2",
"@sentry/utils": "8.9.2"
"@sentry-internal/browser-utils": "8.10.0",
"@sentry-internal/feedback": "8.10.0",
"@sentry-internal/replay": "8.10.0",
"@sentry-internal/replay-canvas": "8.10.0",
"@sentry/core": "8.10.0",
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0"
},
"engines": {
"node": ">=14.18"
}
},
"node_modules/@sentry/core": {
"version": "8.9.2",
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.9.2.tgz",
"integrity": "sha512-ixm8NISFlPlEo3FjSaqmq4nnd13BRHoafwJ5MG+okCz6BKGZ1SexEggP42/QpGvDprUUHnfncG6WUMgcarr1zA==",
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.10.0.tgz",
"integrity": "sha512-NzrFqYsEHMd4TYYYxOvf+f+Z02u0nt12cIYYN9pOM3xBLKR+ORs7jhVnN0cB/H2yqtmtBaIzSehk/M/qUXFJGw==",
"dependencies": {
"@sentry/types": "8.9.2",
"@sentry/utils": "8.9.2"
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0"
},
"engines": {
"node": ">=14.18"
}
},
"node_modules/@sentry/types": {
"version": "8.9.2",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-8.9.2.tgz",
"integrity": "sha512-+LFOyQGl+zk5SZRGZD2MEURf7i5RHgP/mt3s85Rza+vz8M211WJ0YsjkIGUJFSY842nged5QLx4JysLaBlLymg==",
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-8.10.0.tgz",
"integrity": "sha512-6kgh6NqgQHcnnD7dOe3THcVkzv2nor/f94x3odmPShN2AWBfPRprHZZsLTjh/3aC7l76V2nfuQ4wgRvwsddTWw==",
"engines": {
"node": ">=14.18"
}
},
"node_modules/@sentry/utils": {
"version": "8.9.2",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-8.9.2.tgz",
"integrity": "sha512-A4srR9mEBFdVXwSEKjQ94msUbVkMr8JeFiEj9ouOFORw/Y/ux/WV2bWVD/ZI9wq0TcTNK8L1wBgU8UMS5lIq3A==",
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-8.10.0.tgz",
"integrity": "sha512-tQPgB7lX1XqbEw2EXvWNsBQlmG+yJHVhBKKDPy5HZMjuTP3zlpVdP6NF87qwonmdtFNHxdrKbfOVRiLx71/JwA==",
"dependencies": {
"@sentry/types": "8.9.2"
"@sentry/types": "8.10.0"
},
"engines": {
"node": ">=14.18"
@ -13687,15 +13687,16 @@
"license": "ISC"
},
"node_modules/glob": {
"version": "10.4.1",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.1.tgz",
"integrity": "sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw==",
"version": "10.4.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz",
"integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==",
"dev": true,
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^3.1.2",
"minimatch": "^9.0.4",
"minipass": "^7.1.2",
"package-json-from-dist": "^1.0.0",
"path-scurry": "^1.11.1"
},
"bin": {
@ -17186,6 +17187,12 @@
"node": ">=6"
}
},
"node_modules/package-json-from-dist": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz",
"integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==",
"dev": true
},
"node_modules/pako": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",

View File

@ -46,7 +46,7 @@
"@open-wc/lit-helpers": "^0.7.0",
"@patternfly/elements": "^3.0.2",
"@patternfly/patternfly": "^4.224.2",
"@sentry/browser": "^8.9.2",
"@sentry/browser": "^8.10.0",
"@webcomponents/webcomponentsjs": "^2.8.0",
"base64-js": "^1.5.1",
"chart.js": "^4.4.3",
@ -108,7 +108,7 @@
"eslint-plugin-sonarjs": "^0.25.1",
"eslint-plugin-storybook": "^0.8.0",
"github-slugger": "^2.0.0",
"glob": "^10.4.1",
"glob": "^10.4.2",
"lit-analyzer": "^2.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.2",

View File

@ -16,8 +16,8 @@ The most common types are:
### Add a new integration
To add documentation for a new integration (with support level Community or Vendor), please use the integration templates [`service.md`](https://github.com/goauthentik/authentik/blob/main/website/integrations/_template/service.md) from our GitHub repo. You can download the template using the following command:
To add documentation for a new integration (with support level Community or Vendor), please use the integration templates [`service.md`](https://github.com/goauthentik/authentik/blob/main/website/integrations/template/service.md) from our GitHub repo. You can download the template using the following command:
```shell
wget https://raw.githubusercontent.com/goauthentik/authentik/main/website/integrations/_template/service.md
wget https://raw.githubusercontent.com/goauthentik/authentik/main/website/integrations/template/service.md
```

View File

@ -48,7 +48,7 @@ Following the guidelines will make getting your PRs merged much easier and faste
In addition to following the [Style Guide](./style-guide.mdx) please review the following guidelines.
For new integration documentation, please use the Integrations template in our [Github repo](https://github.com/goauthentik/authentik) at `/website/integrations/_template/service.md`.
For new integration documentation, please use the Integrations template in our [Github repo](https://github.com/goauthentik/authentik) at `/website/integrations/template/service.md`.
- Make sure to add the service to a fitting category in `/website/sidebarsIntegrations.js`. If this is not done the service will not appear in the table of contents to the left.

View File

@ -123,7 +123,7 @@ This is documented in the [developer docs](./setup/frontend-dev-environment.md)
Contributions to the technical documentation are greatly appreciated. Open a PR if you have improvements to make or new content to add. If you have questions or suggestions about the documentation, open an Issue. No contribution is too small.
Please be sure to refer to our [Style Guide](../developer-docs/docs/style-guide.mdx) for the docs, and use a [template](./docs/templates/index.md) to make it easier for you. The style guidelines are also used for any Integrations documentation, and we have a template for Integrations as well, in our [Github repo](https://github.com/goauthentik/authentik) at `/website/integrations/_template/service.md`.
Please be sure to refer to our [Style Guide](../developer-docs/docs/style-guide.mdx) for the docs, and use a [template](./docs/templates/index.md) to make it easier for you. The style guidelines are also used for any Integrations documentation, and we have a template for Integrations as well, in our [Github repo](https://github.com/goauthentik/authentik) at `/website/integrations/template/service.md`.
### Pull Requests

View File

@ -48,7 +48,7 @@ location / {
# all requests to /outpost.goauthentik.io must be accessible without authentication
location /outpost.goauthentik.io {
proxy_pass http://outpost.company:9000/outpost.goauthentik.io;
proxy_pass http://outpost.company:9000;
# ensure the host of this vserver matches your external URL you've configured
# in authentik
proxy_set_header Host $host;

View File

@ -52,7 +52,7 @@ server {
# all requests to /outpost.goauthentik.io must be accessible without authentication
location /outpost.goauthentik.io {
proxy_pass http://outpost.company:9000/outpost.goauthentik.io;
proxy_pass http://outpost.company:9000;
# ensure the host of this vserver matches your external URL you've configured
# in authentik
proxy_set_header Host $host;

View File

@ -11,9 +11,9 @@ To try out the release candidate, replace your Docker image tag with the latest
## Highlights
- **PostgreSQL read-replica** Optimize database query routing by using read-replicas to balance the load
- **New Enterprise providers** <span class="badge badge--primary">Enterprise</span> <span class="badge badge--info">Preview</span> Google Workspace and Microsoft Entra ID providers allows for user synchronization with authentik
- **Improved CAPTCHA stage** Allows configurable dynamic use of CAPTCHAs
- **PostgreSQL read replicas**: Optimize database query routing by using read replicas to balance the load
- **New Enterprise providers**: <span class="badge badge--primary">Enterprise</span> <span class="badge badge--info">Preview</span> Google Workspace and Microsoft Entra ID providers allow for user synchronization with authentik
- **Improved CAPTCHA stage**: Allows configurable dynamic use of CAPTCHAs
## Breaking changes

View File

@ -17,10 +17,10 @@ Below is a list of all applications that are known to work with authentik. All a
### Add a new application
To add documentation for a new application (with support level Community or Vendor), please use the integration template [`service.md`](https://github.com/goauthentik/authentik/blob/main/website/integrations/_template/service.md) file from our GitHub repo. You can download the template file using the following command:
To add documentation for a new application (with support level Community or Vendor), please use the integration template [`service.md`](https://github.com/goauthentik/authentik/blob/main/website/integrations/template/service.md) file from our GitHub repo. You can download the template file using the following command:
```shell
wget https://raw.githubusercontent.com/goauthentik/authentik/main/website/integrations/_template/service.md
wget https://raw.githubusercontent.com/goauthentik/authentik/main/website/integrations/template/service.md
```
Don't forget to edit the `sidebarsIntegrations.js` file to add your new integration to the lefthand navigation bar.