You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "henry3260 (via GitHub)" <gi...@apache.org> on 2026/09/08 05:56:30 UTC
[PR] Scope asset API responses to the assets a user may read [airflow]
henry3260 opened a new pull request, #72682:
URL: https://github.com/apache/airflow/pull/72682
## Why
`GET /api/v2/assets`, `GET /ui/assets` and `GET /api/v2/assets/events` run a single coarse `is_authorized_asset` check and then return every row. In a multi-team deployment every caller therefore sees every other team's asset names and URIs, which commonly encode bucket, table or dataset names. Dags, connections, pools and variables already scope their list endpoints to what the caller may read; assets had no equivalent.
Auth managers also had no way to express such a rule. `AssetDetails` only carried the numeric `id`, so a manager that wants to authorize by URI prefix or by name had nothing to decide on, on list and single-asset endpoints alike.
## What
- `AssetDetails` gains `name` and `uri`.
- `BaseAuthManager` gains `get_authorized_assets` and `filter_authorized_assets`, following the existing connection pattern. The default implementation calls `is_authorized_asset` per asset, so a deployment whose manager ignores asset details keeps today's behaviour.
- `security.py` gains `PermittedAssetFilter`, `PermittedAssetEventByAssetFilter`, `permitted_asset_filter_factory` and the two `Readable*FilterDep` aliases. The public and UI asset list endpoints and the asset events endpoint are scoped with them, so both the returned rows and `total_entries` reflect only readable assets. Events whose asset row is gone stay visible, like events with no source Dag, since there is nothing left to authorize on.
- `requires_access_asset` resolves the asset's name and uri before calling `is_authorized_asset`, so single-asset routes such as `/assets/{asset_id}` and `/assets/{asset_id}/queuedEvents` can be authorized by URI or name too. Backed by a new `AssetModel.get_name_and_uri`.
- Auth manager docs list `filter_authorized_assets` among the methods recommended to override.
- Tests cover the new auth manager methods, the filters and factory, the enriched `requires_access_asset`, and the three endpoints end to end. Query-count assertions on the touched endpoints go up by one for the extra authorization query.
Provider auth managers (Keycloak, AWS) may want to override `filter_authorized_assets` for batching, as they already do for connections. Left for a follow-up on the provider side.
closes: #72333
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 5)
Generated-by: Claude Code (Opus 5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Scope asset API responses to the assets a user may read [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #72682:
URL: https://github.com/apache/airflow/pull/72682#issuecomment-5603585131
> > Assets are global to the environment. They do not belong to any team.
>
> Thanks for taking a look, and that's a fair point you're right that assets are global and don't belong to any team. I should clarify that this PR doesn't try to change that; it doesn't introduce any team-to-asset ownership.
>
> What it's really after is authorization granularity. Right now the asset list,events endpoints run a single coarse `is_authorized_asset` check and then return every row, and the auth manager only ever receives an opaque numeric `id`. This PR simply passes the asset's `name` and `uri` along, so an auth manager _can_ decide readability per asset (say, by URI prefix) if it chooses to. Whether a deployment actually restricts anything stays entirely in the auth manager's hands the default still calls `is_authorized_asset` per asset, so nothing changes for managers that don't care about asset identity.
>
> My thinking was to mirror what connections, pools and variables already do: those are global too, yet their list endpoints are still scoped to what the caller may read, and assets were the one exception with no way to express that.
>
> That said, I may well be missing context here would you prefer that we not scope global assets at all, or is it more about how the filtering is done? Happy to adjust either way.
Oh I see now! Alright, let me take a look :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Scope asset API responses to the assets a user may read [airflow]
Posted by "henry3260 (via GitHub)" <gi...@apache.org>.
henry3260 commented on PR #72682:
URL: https://github.com/apache/airflow/pull/72682#issuecomment-5604000675
Should this go into 3.4 or a 3.3.x patch release?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Scope asset API responses to the assets a user may read [airflow]
Posted by "henry3260 (via GitHub)" <gi...@apache.org>.
henry3260 commented on PR #72682:
URL: https://github.com/apache/airflow/pull/72682#issuecomment-5603401979
> Assets are global to the environment. They do not belong to any team.
Thanks for taking a look, and that's a fair point you're right that assets are global and don't belong to any team. I should clarify that this PR doesn't try to change that; it doesn't introduce any team-to-asset ownership.
What it's really after is authorization granularity. Right now the asset list,events endpoints run a single coarse `is_authorized_asset` check and then return every row, and the auth manager only ever receives an opaque numeric `id`. This PR simply passes the asset's `name` and `uri` along, so an auth manager *can* decide readability per asset (say, by URI prefix) if it chooses to. Whether a deployment actually restricts anything stays entirely in the auth manager's hands the default still calls `is_authorized_asset` per asset, so nothing changes for managers that don't care about asset identity.
My thinking was to mirror what connections, pools and variables already do: those are global too, yet their list endpoints are still scoped to what the caller may read, and assets were the one exception with no way to express that.
That said, I may well be missing context here would you prefer that we not scope global assets at all, or is it more about how the filtering is done? Happy to adjust either way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Scope asset API responses to the assets a user may read [airflow]
Posted by "henry3260 (via GitHub)" <gi...@apache.org>.
henry3260 commented on PR #72682:
URL: https://github.com/apache/airflow/pull/72682#issuecomment-5587548484
This scopes the asset collection endpoints to the assets the caller may read,
and gives auth managers the `name` and `uri` they need to make that decision:
- `GET /assets` and `GET /ui/assets` — filtered rows and `total_entries`
- `GET /assets/events` — filtered by the event's asset
- every `/assets/{asset_id}/...` route — `requires_access_asset` now resolves
the asset's name and uri, so an auth manager can deny per asset rather than seeing an opaque id
It does not extend to endpoints that return an asset inside a response which is not an asset collection. Those still authorize on the coarse `requires_access_asset` check alone:
| Endpoint | What it would need |
|---|---|
| `POST /assets/events` | the asset id read from the request body — `requires_access_asset` reads path parameters, so it authorizes on `id=None` |
| `GET /dags/{dag_id}/dagRuns/{dag_run_id}/upstreamAssetEvents` | the event filter, applied where the run's events are serialized |
| `GET /ui/next_run_assets/{dag_id}` | an asset filter alongside the existing Dag check |
| `GET /ui/partitioned_dag_runs`, `GET /ui/pending_partitioned_dag_run/{dag_id}` | same |
| `GET /ui/dependencies?dependency_type=data` | asset-level gating; today it hides the graph unless the caller can read a connected Dag |
| `GET /assets/aliases` | a decision on whether alias names fall under asset authorization |
Each needs its own call on where the filter belongs, and I would rather settle the shared filter and the auth manager interface first. Happy to fold any of them in if reviewers would prefer this land as one change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Scope asset API responses to the assets a user may read [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #72682:
URL: https://github.com/apache/airflow/pull/72682#issuecomment-5604038233
Definitely 3.4
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Scope asset API responses to the assets a user may read [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #72682:
URL: https://github.com/apache/airflow/pull/72682
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org