Skip to content

policies: support dry-run bindings with event reporting - #26382

Merged
BeryJu merged 10 commits into
goauthentik:mainfrom
jsachs:feature/policy-dry-run-events
Oct 1, 2026
Merged

BeryJu merged 10 commits into
goauthentik:mainfrom
jsachs:feature/policy-dry-run-events

Conversation

@jsachs

@jsachs jsachs commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Details

What does this PR change?

Adds a per-binding dry-run option for policies and direct user/group bindings.

  • Evaluates dry-run bindings without including their results or messages in the final access decision.
  • Records observations using the existing POLICY_EXECUTION event action, including when policy execution logging is disabled.
  • Reports policy cache hits with a cache indicator. Static user/group checks are evaluated without caching.
  • Supports single-target evaluation and both bulk policy engines, including observations for users or targets already excluded by enforced static bindings.
  • Adds Event Log search suggestions for binding ID, dry-run status, and cache status.
  • Adds the model migration, API field, and generated schema/client updates.

Why is this change needed?

Administrators need to understand which access rules would match before enforcing them. Currently, enabling a binding immediately affects access, while disabling it prevents evaluation entirely.

Dry-run allows administrators to observe results over time through the Event Log before switching a binding to enforcement. The setting belongs to the binding, so the same policy can be enforced on one target and observed on another.

This reuses an existing event action and does not store results in flow context. Dry-run does not prevent policy side effects. UI controls and documentation are handled in the stacked follow-up.

How was this tested?

  • Backend regression run: 120 tests passed, including policy engine, event API, and flow planner coverage.
  • After the final review corrections, the affected engine, process, and static-reporting suites passed: 37 tests.
  • Added coverage for static user/group observations across all three engines, nested groups, negation, disabled/expired bindings, and empty-result behavior.
  • Verified fresh and cached execution events, binding-specific event searches, HTTP-backed attribution to evaluated users, and targeted bulk cache prefetching.
  • Python formatting and Ruff checks passed. Generated TypeScript client checks and compilation passed.

Linked issues

#18792

@netlify

netlify Bot commented Sep 23, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit aa4c1f5
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6ab3b0c9605d0c0007543fde
😎 Deploy Preview https://deploy-preview-26382--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.23954% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.11%. Comparing base (6b250cc) to head (9397527).

Files with missing lines Patch % Lines
authentik/policies/engine.py 96.87% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26382      +/-   ##
==========================================
+ Coverage   92.00%   92.11%   +0.10%     
==========================================
  Files        1177     1178       +1     
  Lines       76842    77077     +235     
  Branches     4121     4121              
==========================================
+ Hits        70699    70997     +298     
+ Misses       6090     6027      -63     
  Partials       53       53              
Flag Coverage Δ
conformance 33.21% <7.60%> (-0.10%) ⬇️
e2e 37.97% <7.98%> (+0.35%) ⬆️
integration 29.53% <2.28%> (-0.53%) ⬇️
rust 44.79% <ø> (ø)
unit 93.63% <99.23%> (+0.02%) ⬆️
unit-migrate 93.65% <99.23%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@jsachs jsachs changed the title Feature/policy dry run events policies: support dry-run bindings with event reporting Sep 24, 2026
@jsachs
jsachs marked this pull request as ready for review September 24, 2026 14:05
@jsachs
jsachs requested review from a team as code owners September 24, 2026 14:05

@BeryJu BeryJu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Comment thread authentik/events/api/events.py Resolved
@BeryJu
BeryJu merged commit 1ec72f8 into goauthentik:main Oct 1, 2026
139 checks passed
kensternberg-authentik added a commit that referenced this pull request Oct 1, 2026
* main:
  root: fix Makefile documentation (#26597)
  website/docs: update single logout instructions (#26571)
  policies: support dry-run bindings with event reporting (#26382)
  web/admin: update oauth federated provider helptext wording (#26611)
  lib: remove spotlight (#26613)
kensternberg-authentik added a commit that referenced this pull request Oct 1, 2026
* main: (122 commits)
  root: fix Makefile documentation (#26597)
  website/docs: update single logout instructions (#26571)
  policies: support dry-run bindings with event reporting (#26382)
  web/admin: update oauth federated provider helptext wording (#26611)
  lib: remove spotlight (#26613)
  web/admin: show agent connector local auth & compliance status (#26610)
  stages/authenticator_webauthn: Update FIDO MDS3 & Passkey aaguid blobs (#26599)
  core, web: update translations (#26598)
  core: bump goauthentik/fips-python from `95e9d8f` to `9bee9dc` in /lifecycle/container (#26607)
  core: bump goauthentik/platform-ssh from 26.04-ak-0.63.0 to 26.04-ak-0.63.1 in /tests/e2e (#26604)
  core: bump axllent/mailpit from v1.31.2 to v1.31.3 in /tests/e2e (#26601)
  core: bump coverage[toml] from 7.16.1 to 7.16.2 (#26605)
  core: bump cryptography from 50.0.1 to 50.0.2 (#26606)
  core: bump goauthentik/selenium from 152.0-ak-0.63.0 to 152.0-ak-0.63.1 in /tests/e2e (#26602)
  core: bump types-docker from 7.2.0.20260827 to 7.2.0.20260923 in the types group (#26603)
  core/applications: make client_ip a part of the UserApplicationCacheKey (#26553)
  root: fix broken brand logo (#26588)
  core: second cache-clear not needed in policies (#26551)
  stages/authenticator_validate: fix event noise from updated models (#26584)
  enterprise/requests: require either brand or rule request flow (#26585)
  ...
@jsachs
jsachs deleted the feature/policy-dry-run-events branch October 2, 2026 16:53
@jsachs jsachs mentioned this pull request Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants