Repository navigation
Enforce the REST plugin route security checks on Airflow 3 [Backport #36145 - 2.0] - #36337
Conversation
* 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)
❌ 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 |
Code Review ✅ Approved🔴 High risk · Airflow 3 plugin routes now enforce authentication and permissions; incorrect identity or action mapping could expose protected operations or deny legitimate access. Enforces authentication and per-route authorization on the Airflow 3 managed-API plugin routes, which previously ran without any auth checks, failing closed on missing or invalid credentials. Airflow 2 behavior is unchanged. No issues found. 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 |
|



Describe your changes:
Backport of #36145 to
2.0(cherry-pick -x of7c0f10c3782). Security tracking: open-metadata/openmetadata-collate#7795 §5 (Fable H5).On Airflow 3 the managed-API plugin's
requires_access_decoratorwas a pass-through, so every/pluginsv2/api/v2/openmetadata/*route ran without authentication. 2.0 ships Airflow 3.3.2, so every 2.0.x image is affected. This makes the Airflow 3 path authenticate (registered API auth backends, thenAuthorization: Basicagainst the configured auth manager) and authorize each route's(action, resource)list through the auth manager, failing closed. Airflow 2 is unchanged. The design is recorded in the included ADR.Backport deltas from main: the conflict was typing/noqa drift only (2.0 predates #31643). The resolved file matches the fix commit, plus
# noqa: PLC0415on the lazy imports, because 2.0's ruff config still enforces PLC0415.Type of change:
Tests:
openmetadata-airflow-apis/tests/unit/test_security_compat.py: 30 passed on Airflow 3.3.2 (run insideopenmetadata/ingestion:2.0.5with this branch's code)ruff check/ruff format --checkwithingestion/pyproject.tomlonopenmetadata-airflow-apis/: cleanManual testing (real deployment)
Ran the shipped
openmetadata/ingestion:2.0.5image: stockingestion_dependency.sh, SimpleAuthManager, realairflow api-server, plus an extraviewerSimpleAuthManager user. Tested all 12 decorated routes, as shipped and with this branch'ssecurity_compat.pymounted:enable+triggerqueued a real DagRun ofsample_lineage;/statusand/ipreturned data401on every route, handler not run403oncan_create/can_edit/can_deleteroutes;can_readroutes dispatchhealth-auth200,triggerqueued a run,csrf-token200)/healthstays unauthenticated by design.Checklist:
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable issue was established.Summary
This PR replaces the Airflow 3 pass-through decorator with authentication and route permission checks.
No actionable defect was established.
Acknowledgments:
ulixius9explicitly describes anonymous access undersimple_auth_manager_all_admins, Basic fallback after backend rejection, and unsupported bearer tokens as intentional in the included decision record.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Decorated request] --> B{Airflow 2?} B -->|Yes| C[Delegate to existing security decorator] B -->|No| D[Try registered API backends] D --> E{Caller identified?} E -->|No| F[Try configured auth manager with Basic credentials] F --> G{Caller identified?} G -->|No or error| H[Return 401] E -->|Yes| I[Check every route permission] G -->|Yes| I I -->|Denied or error| J[Return 403] I -->|All granted| K[Run handler]Reviews (1) · Last reviewed commit: "Enforce the REST plugin route security c..." · Reviewed by Greptile