Skip to content

Enforce the REST plugin route security checks on Airflow 3 [Backport #36145 - 2.0] - #36337

Merged
ulixius9 merged 1 commit into
2.0from
backport/36145-airflow3-auth-2.0
Oct 27, 2026
Merged

ulixius9 merged 1 commit into
2.0from
backport/36145-airflow3-auth-2.0

Conversation

@ulixius9

@ulixius9 ulixius9 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Backport of #36145 to 2.0 (cherry-pick -x of 7c0f10c3782). Security tracking: open-metadata/openmetadata-collate#7795 §5 (Fable H5).

On Airflow 3 the managed-API plugin's requires_access_decorator was 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, then Authorization: Basic against 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: PLC0415 on the lazy imports, because 2.0's ruff config still enforces PLC0415.

Type of change:

  • Bug fix

Tests:

  • openmetadata-airflow-apis/tests/unit/test_security_compat.py: 30 passed on Airflow 3.3.2 (run inside openmetadata/ingestion:2.0.5 with this branch's code)
  • ruff check / ruff format --check with ingestion/pyproject.toml on openmetadata-airflow-apis/: clean

Manual testing (real deployment)

Ran the shipped openmetadata/ingestion:2.0.5 image: stock ingestion_dependency.sh, SimpleAuthManager, real airflow api-server, plus an extra viewer SimpleAuthManager user. Tested all 12 decorated routes, as shipped and with this branch's security_compat.py mounted:

none / bad password / junk bearer viewer admin (the OM server's basic auth)
2.0.5 as shipped handler runs. Anonymous enable + trigger queued a real DagRun of sample_lineage; /status and /ip returned data handler runs handler runs
this branch 401 on every route, handler not run 403 on can_create/can_edit/can_delete routes; can_read routes dispatch dispatches (health-auth 200, trigger queued a run, csrf-token 200)

/health stays unauthenticated by design.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence 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.

  • Airflow 3 routes now verify callers before running handlers.
  • Airflow 3 routes now require every listed permission before dispatch.

No actionable defect was established.

Acknowledgments: ulixius9 explicitly describes anonymous access under simple_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]
Loading

Reviews (1) · Last reviewed commit: "Enforce the REST plugin route security c..." · Reviewed by Greptile

* 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)
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 27, 2026
@gitar-bot

gitar-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
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.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@ulixius9
ulixius9 merged commit d8cf2e1 into 2.0 Oct 27, 2026
61 of 66 checks passed
@ulixius9
ulixius9 deleted the backport/36145-airflow3-auth-2.0 branch October 27, 2026 12:18

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants