Copilot commented on code in PR #75653:
URL: https://github.com/apache/airflow/pull/75653#discussion_r4718990889
##########
airflow-core/src/airflow/api_fastapi/execution_api/security.py:
##########
@@ -511,7 +511,10 @@ async def get_team_name_dep(
async with create_session_async() as session:
if isinstance(token, (DagProcessorToken, DagParseToken)):
return await session.scalar(_team_name_for_bundle_stmt(dag_bundle))
- return await session.scalar(_team_name_for_ti_stmt(token.id))
+ team_name = await session.scalar(_team_name_for_ti_stmt(token.id))
+ if team_name is not None:
+ return team_name
+ return await session.scalar(_team_name_for_callback_stmt(token.id))
Review Comment:
Resolving callback tokens to a team changes authorization for existing
Execution API clients, but no Cadwyn migration records the change.
`contributing-docs/19_execution_api_versioning.rst:40-59` requires a CalVer
migration and versioned tests for client-visible behavior changes. Please
register this change in the appropriate version and test callback access
through the affected API versions.
##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_xcoms.py:
##########
@@ -1827,3 +1829,29 @@ def test_teamless_requester_scoping(self, client,
session, dag_maker):
assert forbidden.status_code == 403, forbidden.json()
assert allowed.status_code == 200, allowed.json()
+
+ def test_callback_requester_team_scoping(self, client, exec_app, session,
dag_maker):
+ """An execution token exchanged for a callback resolves its team via
Callback.bundle_name."""
+ team_a_dag = f"team_a_{uuid4().hex}"
+ team_a_dr, _ = self._make_dag(session, dag_maker, team_a_dag, "team_a")
+ self._insert_xcom(session, team_a_dr, key="k", value="v")
+
+ team_b_dag = f"team_b_{uuid4().hex}"
+ self._make_dag(session, dag_maker, team_b_dag, "team_b")
+
+ callback = ExecutorCallback(
+ callback_def=SyncCallback("os.getpid", kwargs={}),
+ fetch_method=CallbackFetchMethod.IMPORT_PATH,
+ )
+ callback.bundle_name = f"bundle-{team_a_dag}"
+ session.add(callback)
+ session.commit()
+ self._authenticate_as(exec_app, callback.id)
+
+ with conf_vars({("core", "multi_team"): "True"}):
+ same_team = client.get(self._url(team_a_dag, key="k"))
+ other_team = client.get(self._url(team_b_dag, key="k"))
+
+ assert same_team.status_code == 200, same_team.json()
+ assert same_team.json() == {"key": "k", "value": "v"}
+ assert other_team.status_code == 403, other_team.json()
Review Comment:
This test covers only GET, but resolving a callback's team also changes
POST/DELETE authorization. Add callback-token cases that allow same-team
mutations and reject mutations of global and other-team XComs. In particular,
global mutations must return 403 rather than treating the callback as teamless.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]