Skip to content

Enforce the REST plugin route security checks on Airflow 3 - #36145

Merged
TeddyCr merged 3 commits into
open-metadata:mainfrom
TeddyCr:worktree-airflow3-auth-hardening
Oct 27, 2026
Merged

TeddyCr merged 3 commits into
open-metadata:mainfrom
TeddyCr:worktree-airflow3-auth-hardening

Conversation

@TeddyCr

@TeddyCr TeddyCr commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

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 the
handler 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 in
openmetadata_managed_apis/utils/security_compat.py returned a pass-through on that
path. 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):

  • authentication — first through the API auth backends Airflow registered on the
    Flask app (app.api_auth, sourced from [fab] auth_backends); when none accepts the
    request, through Authorization: Basic credentials checked against the configured
    auth manager's own credential store: SimpleAuthManager's configured users and
    password 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;
  • authorization — the configured auth manager (get_auth_manager()) must grant
    every (action, resource) tuple carried by the route to the authenticated user,
    through the Airflow 3 auth manager API (is_authorized_dag for the DAG resource,
    is_authorized_custom_view otherwise). SimpleAuthManager roles are therefore
    honoured: a viewer reaches the can_read routes 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 — the
decorator 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
SimpleAuthManager users the ingestion entrypoint already provisions (or the FAB users
on a FAB auth manager deployment). No [fab] auth_backends change is needed.

Type of change:

  • Bug fix

High-level design:

N/A — small change (one module + its tests + a decision record).

Tests:

Use cases covered

  • Requests without valid credentials are rejected (401) on all REST plugin routes on
    Airflow 3, and the handler is not executed
  • Valid basic credentials with the required DAG permission dispatch (200), checked
    against both the FAB user store and the real SimpleAuthManager (users + password
    file)
  • Invalid password / unknown user / non-basic Authorization scheme are rejected
    (401)
  • A user lacking the route's required DAG permission is rejected (403), including a
    SimpleAuthManager viewer on a can_edit route and a route listing several
    permissions of which one is missing
  • A registered API auth backend (session) still admits a logged-in user, and its
    rejection does not block valid basic credentials
  • Unavailable or mis-resolved auth manager rejects rather than dispatches (fail closed);
    an action outside the known FAB actions is denied
  • simple_auth_manager_all_admins keeps its Airflow semantics (anonymous admin)
  • Airflow 2 deployments keep delegating to airflow.api_connexion (no behavior change)

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated:
    • openmetadata-airflow-apis/tests/unit/test_security_compat.py — request-level
      tests 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 SimpleAuthManager
      tests 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_decorator
      now 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 SimpleAuthManager cases are parametrized over both shapes of its static
      API: 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 TypeError on 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 (SimpleAuthManager tests);
make py_format_check clean.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (plugin-only change).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Verified against a local Airflow 3.3.2 deployment with apache-airflow-providers-fab
3.10.1, driving the plugin Flask app exactly as the API server mounts it under
/pluginsv2 (auth manager initialised first, then the FAB create_app(enable_plugins=True)),
under three configurations: SimpleAuthManager with the ingestion entrypoint's settings
(users + password file, [api] auth_backends as shipped), FabAuthManager with the
default [fab] auth_backends (session only), and FabAuthManager with
[fab] auth_backends = basic_auth,session. All three give:

Request Result
no credentials 401, handler not executed
valid basic credentials (admin), permitted action 200, dispatched
invalid basic credentials 401
valid credentials (viewer), can_delete route 403
valid credentials (admin), can_delete route 200

Also verified the Airflow 2.x path on 2.10.5 (airflow.api_connexion present): the
decorator resolves the framework security module and request-level behavior is
unchanged.

UI screen recording:

Not applicable — backend-only change (no UI impact).

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable).
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
  • Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under docs/decisions/ (see its README.md). This description is gone from git log after the squash-merge.
  • I have added a test that covers the exact scenario we are fixing (the request-level
    unit tests cover the route-level checks end to end).

🤖 Generated with Claude Code

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

  • Airflow 3 plugin routes check identity and permissions before running handlers.

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]
Loading

Reviews (3) · Last reviewed commit: "Airflow 3 plugin routes: drive SimpleAut..." · Reviewed by Greptile

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.
Copilot AI balanced review requested due to automatic review settings October 23, 2026 23:18
@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

…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/.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 18:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Oct 26, 2026
… 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.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 19:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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

gitar-bot Bot commented Oct 26, 2026

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

📄 openmetadata-airflow-apis/openmetadata_managed_apis/utils/security_compat.py:140-154
On Airflow 3, _check_authentication only trusts current_app.api_auth. The FAB provider builds that list in init_api_auth from [fab] auth_backends, which defaults to the session backend and does not fall back to [api] auth_backends (init_security.py). Every deployment shipped from this repo sets only AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.basic_auth,...: ingestion/ingestion_dependency.sh:31, the docker-compose files, .github/scripts/start_playwright_fast_environment.sh and development/airflow/airflow.cfg. Airflow 3 also removed the airflow.api.auth.backend.basic_auth module. The ingestion image pins apache-airflow==3.3.2, so app.api_auth ends up holding only the session backend.

AirflowRESTClient sends Authorization: Basic with no session to /pluginsv2/.../health-auth and to every other route. Each of those requests now gets a 401. Version detection then fails, and the OpenMetadata server can no longer deploy, trigger or check status on any pipeline. This contradicts the description's claim that callers are unaffected.

Fix: in the same PR, set AIRFLOW__FAB__AUTH_BACKENDS=airflow.providers.fab.auth_manager.api.auth.backend.basic_auth,airflow.providers.fab.auth_manager.api.auth.backend.session in the ingestion entrypoint and compose/CI configs. Alternatively, have the decorator try the FAB basic_auth backend when Authorization: Basic is present. Either way, add a test that uses the real FAB backends with the shipped config.

✅ Quality: Plugin-auth contract with OM server is decided but not recorded

📄 openmetadata-airflow-apis/openmetadata_managed_apis/utils/security_compat.py:59-69 📄 openmetadata-airflow-apis/openmetadata_managed_apis/utils/security_compat.py:140-154
This PR sets a rule that the OpenMetadata server and the deployment configuration both have to follow, and nothing in docs/decisions/ records it. The rule comes from the description: "Authentication runs through the API auth backends Airflow registered on the Flask app (app.api_auth, from [fab] auth_backends)" and "Both checks fail closed". As a record it would say: On Airflow 3, every OpenMetadata managed-API plugin route authenticates only through the [fab] auth_backends registered on the Flask app and requires the security manager to grant every listed (action, resource); a route rejects with 401/403 when no backend or security manager resolves, so the OpenMetadata server's Basic-auth client depends on the deployment enabling the FAB basic_auth backend. The repository squash-merges, so the description won't survive in history. Without a record, the requirement that deployments enable FAB basic_auth exists only in the PR body.

✅ Quality: Unauthenticated test misses both the handler and the auth logic

📄 openmetadata-airflow-apis/tests/unit/test_security_compat.py:99-105 📄 openmetadata-airflow-apis/tests/unit/test_security_compat.py:141-145
test_unauthenticated_request_is_rejected_and_handler_not_run never sets app.api_auth, so it gets its 401 from the "no backend registered" branch, not from a backend rejecting an anonymous caller. _decorate_view returns calls, but the fixture throws it away, so the test never checks that the handler didn't run. If a registered backend let an anonymous request through, this test would still pass. Fix: register SessionAuthBackend, skip _login, and assert both the 401 and that calls is empty (for example, store it on the app in the fixture).

✅ Bug: SimpleAuthManager basic auth calls get_passwords()/get_users() wrongly

📄 openmetadata-airflow-apis/openmetadata_managed_apis/utils/security_compat.py:206-220
_simple_auth_manager_user calls auth_manager.get_passwords() with no arguments and reads user.username from each item of auth_manager.get_users(). In Airflow 3.0.0 through 3.1.x both are staticmethods: get_passwords(users) requires the users list, and get_users() returns dicts like {"username": ..., "role": ...}, not SimpleAuthManagerUser objects (3.0.0 source, 3.1.4 source). So whenever simple_auth_manager_all_admins is off, every basic-auth request raises TypeError, and the wrapper turns that into a 401. This is the stock-image path the commit adds so the OpenMetadata server can authenticate, so the server would still be locked out. Even if the call succeeded, it would hand a dict to is_authorized_dag, but SimpleAuthManager needs a SimpleAuthManagerUser with get_role() to authorize. The fix is to pass the users list to get_passwords and build a SimpleAuthManagerUser from the matching dict.

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

@TeddyCr
TeddyCr enabled auto-merge October 26, 2026 19:36
@sonarqubecloud

Copy link
Copy Markdown

@TeddyCr
TeddyCr added this pull request to the merge queue Oct 27, 2026
Merged via the queue into open-metadata:main with commit 7c0f10c Oct 27, 2026
76 of 79 checks passed
@TeddyCr
TeddyCr deleted the worktree-airflow3-auth-hardening branch October 27, 2026 07:55
ulixius9 added a commit that referenced this pull request Oct 27, 2026
…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]>
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