Skip to content

policies: fix policybinding cache invalidation - #25989

Merged
BeryJu merged 9 commits into
goauthentik:mainfrom
jsachs:fix/policybinding-cache-invalidation
Sep 15, 2026
Merged

BeryJu merged 9 commits into
goauthentik:mainfrom
jsachs:fix/policybinding-cache-invalidation

Conversation

@jsachs

@jsachs jsachs commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Details

What does this PR change?

Invalidate cached policy results when either a policy or a policy binding changes. Previously, updated or deleted bindings would not invalidate the policy cache.

Why is this change needed?

This prevents stale negate and failure_result behavior. It is necessary to avoid creating stale dry_run behavior when implemented.

How was this tested?

Signal and engine tests updated.

You can also test manually by doing the following in your local dev environment:

  1. Create a basic application
  2. Create an Expression Policy binding with return True for the new application.
  3. Go to http://localhost:9000/if/user/#/library in another tab. You should see the new application. Now the cache is warm.
  4. Return to the policy binding and enable Negate Result.
  5. Immediately refresh the other tab. The application should immediately disappear.
  6. You can test the same behavior by deleting the policy binding instead of negating it.

Linked issues

#18792


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)
  • I have read the AI usage policy.
  • Most of this work was done in OpenCode with GPT 5.6 Sol.
  • Code was reviewed line-by-line to confirm my understanding of my own changes and each AI-assisted change.

@netlify

netlify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 46c7272
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6aa95a39f45e1b00083f9bd2
😎 Deploy Preview https://deploy-preview-25989--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.

@jsachs
jsachs marked this pull request as ready for review September 9, 2026 18:45
@jsachs
jsachs requested a review from a team as a code owner September 9, 2026 18:45
Comment thread authentik/policies/signals.py Resolved
Comment thread authentik/policies/signals.py Resolved
@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.94%. Comparing base (aba062d) to head (46c7272).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25989      +/-   ##
==========================================
- Coverage   91.97%   91.94%   -0.04%     
==========================================
  Files        1172     1172              
  Lines       75927    75962      +35     
  Branches     4056     4056              
==========================================
+ Hits        69834    69843       +9     
- Misses       6051     6077      +26     
  Partials       42       42              
Flag Coverage Δ
conformance 33.59% <16.00%> (-0.01%) ⬇️
e2e 38.30% <16.00%> (-0.02%) ⬇️
integration 29.87% <6.00%> (-0.46%) ⬇️
rust 42.89% <ø> (ø)
unit 93.53% <100.00%> (+0.01%) ⬆️
unit-migrate 93.54% <100.00%> (+0.01%) ⬆️

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 requested review from a team as code owners September 10, 2026 12:19
@netlify

netlify Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 46c7272
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6aa95a39b83c7b000831ffbc
😎 Deploy Preview https://deploy-preview-25989--authentik-integrations.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.

@netlify

netlify Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 46c7272
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6aa95a3942dc830008408c66
😎 Deploy Preview https://deploy-preview-25989--authentik-storybook.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.

@jsachs
jsachs force-pushed the fix/policybinding-cache-invalidation branch from 2bd6344 to f26e285 Compare September 10, 2026 12:29
@jsachs
jsachs force-pushed the fix/policybinding-cache-invalidation branch from f26e285 to 0050a42 Compare September 10, 2026 12:38
@BeryJu
BeryJu removed request for a team September 15, 2026 14:39
@BeryJu BeryJu added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Sep 15, 2026
@BeryJu
BeryJu merged commit ffaf524 into goauthentik:main Sep 15, 2026
138 checks passed
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #26178

@jsachs
jsachs deleted the fix/policybinding-cache-invalidation branch September 15, 2026 20:20
BeryJu added a commit that referenced this pull request Sep 17, 2026
… version-2026.8) (#26178)

policies: fix policybinding cache invalidation (#25989)

* invalidate Policy cache when a Policy or PolicyBinding is updated

* policies: normalize binding UUID during cache invalidation

* fix UUID capture bug in blueprints

---------

Co-authored-by: Jacob Sachs <[email protected]>
Co-authored-by: Dewi Roberts <[email protected]>
Co-authored-by: Jens L. <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants