fix: invalidate cached user permissions after LDAP role sync to prevent intermittent 403s#64539
Merged
vincbeck merged 4 commits intoApr 14, 2026
Merged
Conversation
…nt intermittent 403s
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes intermittent 403 Forbidden after LDAP role sync by ensuring cached user permissions (_perms) are invalidated so authorization checks rebuild against the freshly updated DB role state.
Changes:
- Invalidate
User._permsafterupdate_user()commits, including for the merged instance returned bysession.merge(). - Invalidate
User._permsafter LDAP role calculation duringauth_user_ldap(), and refresh/reset before returning the authenticated user. - Add a regression unit test asserting
update_user()clears cached permissions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.py |
Adds _perms cache invalidation in user update + LDAP auth flow to prevent stale-permission 403s. |
providers/fab/tests/unit/fab/auth_manager/security_manager/test_override.py |
Adds a regression test validating permission-cache invalidation on user updates. |
Contributor
Author
vincbeck
reviewed
Apr 13, 2026
Contributor
Author
|
Good catch @vincbeck simplified to just |
Contributor
|
Tests are failing |
Contributor
Author
|
All checks are green now, ready for your review @vincbeck! |
vincbeck
approved these changes
Apr 14, 2026
60 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #64533
Problem
When
AUTH_LDAPis used withAUTH_ROLES_SYNC_AT_LOGIN=TrueandAUTH_USER_REGISTRATION=True, users intermittently receive403 Forbiddenerrors even though they have the correct AD group membership and role mappings.
Logging out and back in (sometimes multiple attempts) resolves the issue.
This affects both the Airflow UI and REST API.
Root Cause
After
AUTH_ROLES_SYNC_AT_LOGINtriggers a role sync on login, thein-memory user object retains a stale cached permissions set (
_perms).Any authorization check that runs immediately after login — before the
cached permissions are rebuilt — uses the old (possibly empty or incomplete)
permission set, resulting in a spurious 403.
Since UI login and REST API basic auth both go through
auth_user_ldap(confirmed in
basic_auth.pyandfab_auth_manager.py), both surfacesare affected.
Fix
_permscache on the user object immediately afterAUTH_ROLES_SYNC_AT_LOGINsyncs roles, so the next permission checkrebuilds from the freshly committed DB state.
_permsinsideupdate_user()after the DB commit, as ageneral safeguard for any user update path.
auth_user_ldap, ensuring the returned user reflects the latest role state.Files Changed
providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.pyproviders/fab/tests/unit/fab/auth_manager/security_manager/test_override.pytest_update_user_clears_cached_permissionsTesting
_permscache cleared →immediate permission check uses fresh roles.
ruff formatandruff check --fixon all modified files — clean.with
AUTH_ROLES_SYNC_AT_LOGIN=True.Checklist
#64533)