Repository navigation
Enforce the REST plugin route security checks on Airflow 3 - #36145
Conversation
airflow.api_connexion was removed in Airflow 3, and the compatibility decorator in requires_access_decorator had degraded to a pass-through on that path, leaving the two checks it used to apply — API authentication through the configured auth backends, and the per-route DAG permission list — to the surrounding web layer, which does not enforce them for plugin Flask blueprints. Reimplement both checks on the Airflow 3 path and fail closed when either mechanism cannot be resolved at request time. Airflow 2 behavior is unchanged: the decorator still delegates to api_connexion, which itself applies the same two checks. Verified on Airflow 3.3.2 with the FAB auth manager against the plugin app exactly as the web layer serves it, plus unit tests for the fail closed paths.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
…onfigured auth manager On Airflow 3 the FAB provider builds `app.api_auth` from `[fab] auth_backends` (session by default) and the stock ingestion image runs SimpleAuthManager, so a decorator that only consults the registered backends rejects the OpenMetadata server's basic-auth client on every route. The decorator now falls back to `Authorization: Basic` credentials checked against the configured auth manager's own store (SimpleAuthManager users + password file, or the FAB security manager), and authorizes through the auth manager API (`is_authorized_dag`) instead of the FAB-only `has_access`, so SimpleAuthManager roles are honoured too. Review follow-ups: the request-level tests now run on Airflow 2 as well (the self-enforced path is patched in rather than skipped), distinguish the authenticated user in the permission check, cover valid / invalid / unpermitted basic credentials against both the FAB store and the real SimpleAuthManager, and assert the handler never runs on a rejection. Ruff findings fixed. Decision recorded under docs/decisions/.
… too Airflow 3.0 and 3.1 ship `get_users()` returning dicts and `get_passwords(users)` taking the user list; 3.2+ return SimpleAuthManagerUser objects and take no argument. The basic-credential check now handles both shapes, builds a SimpleAuthManagerUser from a dict so authorization sees `get_role()`, and the FAB LDAP branch only runs when the LDAP constant is actually importable. Tests parametrize the SimpleAuthManager cases over both API shapes; the suite passes on Airflow 3.3.2, 3.1.4, 3.0.6 and 2.10.5.
Code Review ✅ Approved 4 closed / 4 findings🔴 High risk · Airflow 3 plugin-route authentication and permission checks could admit unauthorized callers or block legitimate requests if identities or grants are misresolved. Enforces the REST plugin route security checks on Airflow 3 by authenticating basic credentials through the configured auth manager and verifying per-route permissions, failing closed on rejection. No open issues remain; resolved items include basic auth returning 401 on shipped deployments, the missing plugin-auth contract record, the unauthenticated test gap, and SimpleAuthManager calls to get_passwords()/get_users(). ✅ 4 closed✅ Bug: Shipped deployments get only the session backend, so OM Basic auth gets 401
✅ Quality: Plugin-auth contract with OM server is decided but not recorded
✅ Quality: Unauthenticated test misses both the handler and the auth logic
✅ Bug: SimpleAuthManager basic auth calls get_passwords()/get_users() wrongly
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
7c0f10c
…36337) * Enforce the REST plugin route security checks on Airflow 3 airflow.api_connexion was removed in Airflow 3, and the compatibility decorator in requires_access_decorator had degraded to a pass-through on that path, leaving the two checks it used to apply — API authentication through the configured auth backends, and the per-route DAG permission list — to the surrounding web layer, which does not enforce them for plugin Flask blueprints. Reimplement both checks on the Airflow 3 path and fail closed when either mechanism cannot be resolved at request time. Airflow 2 behavior is unchanged: the decorator still delegates to api_connexion, which itself applies the same two checks. Verified on Airflow 3.3.2 with the FAB auth manager against the plugin app exactly as the web layer serves it, plus unit tests for the fail closed paths. * Airflow 3 plugin routes: authenticate basic credentials through the configured auth manager On Airflow 3 the FAB provider builds `app.api_auth` from `[fab] auth_backends` (session by default) and the stock ingestion image runs SimpleAuthManager, so a decorator that only consults the registered backends rejects the OpenMetadata server's basic-auth client on every route. The decorator now falls back to `Authorization: Basic` credentials checked against the configured auth manager's own store (SimpleAuthManager users + password file, or the FAB security manager), and authorizes through the auth manager API (`is_authorized_dag`) instead of the FAB-only `has_access`, so SimpleAuthManager roles are honoured too. Review follow-ups: the request-level tests now run on Airflow 2 as well (the self-enforced path is patched in rather than skipped), distinguish the authenticated user in the permission check, cover valid / invalid / unpermitted basic credentials against both the FAB store and the real SimpleAuthManager, and assert the handler never runs on a rejection. Ruff findings fixed. Decision recorded under docs/decisions/. * Airflow 3 plugin routes: drive SimpleAuthManager's 3.0/3.1 static API too Airflow 3.0 and 3.1 ship `get_users()` returning dicts and `get_passwords(users)` taking the user list; 3.2+ return SimpleAuthManagerUser objects and take no argument. The basic-credential check now handles both shapes, builds a SimpleAuthManagerUser from a dict so authorization sees `get_role()`, and the FAB LDAP branch only runs when the LDAP constant is actually importable. Tests parametrize the SimpleAuthManager cases over both API shapes; the suite passes on Airflow 3.3.2, 3.1.4, 3.0.6 and 2.10.5. (cherry picked from commit 7c0f10c) Co-authored-by: Teddy <[email protected]>



Describe your changes:
No issue exists for this — keeping the discussion in the PR.
On Airflow 2, every REST plugin route is wrapped by
airflow.api_connexion.security.requires_access, which applies two checks before thehandler dispatches: authentication through the API auth backends configured for the
deployment, and the per-route
(action, resource)permission list.Airflow 3 removed
airflow.api_connexion, and until now the compatibility decorator inopenmetadata_managed_apis/utils/security_compat.pyreturned a pass-through on thatpath. This change makes the Airflow 3 path apply the same two checks itself, inside the
decorator, before dispatching
(ADR:2026-10-26-airflow3-plugin-routes-authenticate-through-the-configured-auth-manager):
Flask app (
app.api_auth, sourced from[fab] auth_backends); when none accepts therequest, through
Authorization: Basiccredentials checked against the configuredauth manager's own credential store:
SimpleAuthManager's configured users andpassword file (the auth manager the stock ingestion image runs), or the FAB security
manager's user store (LDAP when configured, then the DB), exactly as the FAB basic
auth backend does;
get_auth_manager()) must grantevery
(action, resource)tuple carried by the route to the authenticated user,through the Airflow 3 auth manager API (
is_authorized_dagfor the DAG resource,is_authorized_custom_viewotherwise).SimpleAuthManagerroles are thereforehonoured: a
viewerreaches thecan_readroutes only.Both checks fail closed: if no mechanism establishes the caller, or the auth
manager cannot be reached or denies a listed permission, the request is rejected
(
401/403) and the handler never runs. Airflow 2 behavior is unchanged — thedecorator still delegates to
airflow.api_connexion.Nothing changes for callers or deployment configuration: the OpenMetadata server's
pipeline client keeps authenticating with basic credentials, which are the
SimpleAuthManagerusers the ingestion entrypoint already provisions (or the FAB userson a FAB auth manager deployment). No
[fab] auth_backendschange is needed.Type of change:
High-level design:
N/A — small change (one module + its tests + a decision record).
Tests:
Use cases covered
401) on all REST plugin routes onAirflow 3, and the handler is not executed
200), checkedagainst both the FAB user store and the real
SimpleAuthManager(users + passwordfile)
Authorizationscheme are rejected(
401)403), including aSimpleAuthManagerviewer on acan_editroute and a route listing severalpermissions of which one is missing
rejection does not block valid basic credentials
an action outside the known FAB actions is denied
simple_auth_manager_all_adminskeeps its Airflow semantics (anonymous admin)airflow.api_connexion(no behavior change)Unit tests
openmetadata-airflow-apis/tests/unit/test_security_compat.py— request-leveltests through a Flask client. The self-enforced path is exercised on every Airflow
version (the Airflow 2 delegation contract is asserted separately); assertions are
on observable outcomes (HTTP status, response body, whether the handler ran) and
the permission check distinguishes the authenticated user. The
SimpleAuthManagertests drive the real class with a temporary password file and skip only where
Airflow 3 is not installed.
openmetadata_managed_apis/utils/security_compat.py—requires_access_decoratornow self-enforces on the Airflow 3 path.
docs/decisions/2026-10-26-airflow3-plugin-routes-authenticate-through-the-configured-auth-manager.md— the contract the server and deployments rely on.
The
SimpleAuthManagercases are parametrized over both shapes of its staticAPI: the one Airflow 3.2+ ships (
get_users()returns user objects,get_passwords()) and the one 3.0/3.1 ship (dict users,get_passwords(users)),which the decorator drives without a
TypeErroron those versions.Local runs: Airflow 3.3.2 — 30 passed; Airflow 3.1.4 — 30 passed; Airflow 3.0.6 —
30 passed; Airflow 2.10.5 — 16 passed, 14 skipped (
SimpleAuthManagertests);make py_format_checkclean.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Verified against a local Airflow 3.3.2 deployment with
apache-airflow-providers-fab3.10.1, driving the plugin Flask app exactly as the API server mounts it under
/pluginsv2(auth manager initialised first, then the FABcreate_app(enable_plugins=True)),under three configurations:
SimpleAuthManagerwith the ingestion entrypoint's settings(users + password file,
[api] auth_backendsas shipped),FabAuthManagerwith thedefault
[fab] auth_backends(session only), andFabAuthManagerwith[fab] auth_backends = basic_auth,session. All three give:401, handler not executed200, dispatched401can_deleteroute403can_deleteroute200Also verified the Airflow 2.x path on 2.10.5 (
airflow.api_connexionpresent): thedecorator resolves the framework security module and request-level behavior is
unchanged.
UI screen recording:
Not applicable — backend-only change (no UI impact).
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.docs/decisions/(see itsREADME.md). This description is gone fromgit logafter the squash-merge.unit tests cover the route-level checks end to end).
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was found.Summary
The PR adds authentication and permission checks to Airflow 3 REST plugin routes while preserving Airflow 2 delegation.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD Request[Plugin route request] --> Version{Airflow version} Version -->|2| Delegate[Use Airflow security decorator] Version -->|3| Backend[Try registered API auth backends] Backend -->|No caller| Basic[Check Basic credentials with auth manager] Backend -->|Caller found| Permissions[Check every route permission] Basic -->|Caller found| Permissions Basic -->|Rejected| Unauthorized[Return 401] Permissions -->|Denied or unavailable| Forbidden[Return 403] Permissions -->|Allowed| Handler[Run route handler]Reviews (3) · Last reviewed commit: "Airflow 3 plugin routes: drive SimpleAut..." · Reviewed by Greptile