Skip to content

Commit 02f5850

Browse files
authored
Merge branch 'main' into fix/60000-celery-conf-sdk-migration
2 parents bb3e7b5 + 960c2c5 commit 02f5850

142 files changed

Lines changed: 1372 additions & 644 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ repos:
426426
^airflow-core/src/airflow/models/.*\.py$|
427427
^airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py$|
428428
^airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py$|
429+
^airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_backfills.py$|
430+
^airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_connections.py$|
431+
^airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_pools.py$|
429432
^airflow-core/tests/unit/models/test_serialized_dag.py$|
430433
^airflow-core/tests/unit/models/test_pool.py$|
431434
^airflow-core/tests/unit/models/test_trigger.py$|
@@ -463,6 +466,7 @@ repos:
463466
^airflow-core/tests/unit/utils/test_db_cleanup.py$|
464467
^airflow-core/tests/unit/utils/test_state.py$|
465468
^airflow-core/tests/unit/utils/test_log_handlers.py$|
469+
^airflow-core/tests/unit/ti_deps/deps/test_not_previously_skipped_dep.py$|
466470
^airflow-core/tests/unit/utils/test_types.py$|
467471
^airflow-core/tests/unit/dag_processing/test_manager.py$|
468472
^airflow-core/tests/unit/dag_processing/test_processor.py$|

INTHEWILD.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ Currently, **officially** using Airflow:
332332
1. [LetsBonus](http://www.letsbonus.com) [[@jesusfcr](https://github.com/jesusfcr) & [@OpringaoDoTurno](https://github.com/OpringaoDoTurno)]
333333
1. [Liberty Global](https://www.libertyglobal.com/) [[@LibertyGlobal](https://github.com/LibertyGlobal/)]
334334
1. [liligo](http://liligo.com/) [[@tromika](https://github.com/tromika)]
335-
1. [LINE](https://www.line.me/) [[@uplsh580](https://github.com/uplsh580)]
336335
1. [Lineas](https://lineas.net/) [[@lineashub](https://github.com/lineashub), [@kobethuwis](https://github.com/kobethuwis)]
337336
1. [LingoChamp](http://www.liulishuo.com/) [[@haitaoyao](https://github.com/haitaoyao)]
338337
1. [LinkedIn](http://linkedin.com/) [[@csm10495](https://github.com/csm10495)]
@@ -526,6 +525,7 @@ Currently, **officially** using Airflow:
526525
1. [Tokopedia](https://www.tokopedia.com/) [[@tokopedia](https://github.com/tokopedia)]
527526
1. [Topgolf](https://topgolf.com/)[[@BhaveshSK](https://github.com/BhaveshSK)]
528527
1. [Toplyne](https://toplyne.io)[[@Toplyne](https://github.com/Toplyne/)]
528+
1. [Toss Bank](https://www.tossbank.com/) [[@uplsh580](https://github.com/uplsh580)]
529529
1. [Trade Republic](https://traderepublic.com/)
530530
1. [Trakken](https://www.trkkn.com/) [[@itroulli](https://github.com/itroulli), [@gthar](https://github.com/gthar), [@qulo](https://github.com/qulo), [@Oscar-Rod](https://github.com/Oscar-Rod), [@kondla](https://github.com/kondla), [@semuar](https://github.com/semuar), [@ManuelFreytag](https://github.com/ManuelFreytag)]
531531
1. [Travix](https://www.travix.com/)

airflow-core/docs/core-concepts/auth-manager/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ The following methods aren't required to override to have a functional Airflow a
204204
* ``filter_authorized_dag_ids``: Given a list of Dag IDs, return the list of Dag IDs the user has access to. If not overridden, it calls ``is_authorized_dag`` for every single Dag passes as parameter.
205205
* ``filter_authorized_pools``: Given a list of pool names, return the list of pool names the user has access to. If not overridden, it calls ``is_authorized_pool`` for every single pool passed as parameter.
206206
* ``filter_authorized_variables``: Given a list of variable keys, return the list of variable keys the user has access to. If not overridden, it calls ``is_authorized_variable`` for every single variable passed as parameter.
207+
* ``is_authorized_hitl_task``: Return whether the user is authorized to approve or reject a Human-in-the-loop (HITL) task. Override this method to implement custom authorization logic for HITL tasks. If not overridden, it checks if the user's ID is in the assigned users list.
207208

208209
CLI
209210
^^^

airflow-core/docs/howto/set-up-database.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ By default, Airflow uses **SQLite**, which is intended for development purposes
3232

3333
Airflow supports the following database engine versions, so make sure which version you have. Old versions may not support all SQL statements.
3434

35-
* PostgreSQL: 12, 13, 14, 15, 16
36-
* MySQL: 8.0, `Innovation <https://dev.mysql.com/blog-archive/introducing-mysql-innovation-and-long-term-support-lts-versions>`_
35+
* PostgreSQL: 13, 14, 15, 16, 17
36+
* MySQL: 8.0, 8.4, `Innovation <https://dev.mysql.com/blog-archive/introducing-mysql-innovation-and-long-term-support-lts-versions>`_
3737
* SQLite: 3.15.0+
3838

3939
If you plan on running more than one scheduler, you have to meet additional requirements.

airflow-core/docs/howto/usage-cli.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ The ``db clean`` command works by deleting from each table the records older tha
213213

214214
You can optionally provide a list of tables to perform deletes on. If no list of tables is supplied, all tables will be included.
215215

216+
You can filter cleanup to specific DAGs using ``--dag-ids`` (comma-separated list), or exclude specific DAGs using ``--exclude-dag-ids`` (comma-separated list). These options allow you to target or avoid cleanup for particular DAGs.
217+
216218
You can use the ``--dry-run`` option to print the row counts in the primary tables to be cleaned.
217219

218220
By default, ``db clean`` will archive purged rows in tables of the form ``_airflow_deleted__<table>__<timestamp>``. If you don't want the data preserved in this way, you may supply argument ``--skip-archive``.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``is_authorized_hitl_task()`` method to check whether a user a is authorized to approve a HITL task

airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@ def filter_authorized_menu_items(self, menu_items: list[MenuItem], *, user: T) -
347347
:param user: the user
348348
"""
349349

350+
def is_authorized_hitl_task(self, *, assigned_users: set[str], user: T) -> bool:
351+
"""
352+
Check if a user is allowed to approve/reject a HITL task.
353+
354+
By default, checks if the user's ID is in the assigned_users set.
355+
Auth managers can override this method to implement custom logic.
356+
357+
:param assigned_users: set of user IDs assigned to the task
358+
:param user: the user to check authorization for
359+
"""
360+
return user.get_id() in assigned_users
361+
350362
def batch_is_authorized_connection(
351363
self,
352364
requests: Sequence[IsAuthorizedConnectionRequest],

airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@ def filter_authorized_menu_items(
283283
) -> list[MenuItem]:
284284
return menu_items
285285

286+
def is_authorized_hitl_task(self, *, assigned_users: set[str], user: SimpleAuthManagerUser) -> bool:
287+
"""
288+
Check if a user is allowed to approve/reject a HITL task.
289+
290+
When simple_auth_manager_all_admins=True, all authenticated users are allowed
291+
to approve/reject any task. Otherwise, the user must be in the assigned_users set.
292+
"""
293+
is_simple_auth_manager_all_admins = conf.getboolean("core", "simple_auth_manager_all_admins")
294+
295+
if is_simple_auth_manager_all_admins:
296+
# In all-admin mode, everyone is allowed
297+
return True
298+
299+
# If no assigned_users specified, allow access
300+
if not assigned_users:
301+
return True
302+
303+
# Delegate to parent class for the actual authorization check
304+
return super().is_authorized_hitl_task(assigned_users=assigned_users, user=user)
305+
286306
def get_fastapi_app(self) -> FastAPI | None:
287307
"""
288308
Specify a sub FastAPI application specific to the auth manager.

airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@
5151
UpdateHITLDetailPayload,
5252
)
5353
from airflow.api_fastapi.core_api.openapi.exceptions import create_openapi_http_exception_doc
54-
from airflow.api_fastapi.core_api.security import GetUserDep, ReadableTIFilterDep, requires_access_dag
54+
from airflow.api_fastapi.core_api.security import (
55+
GetUserDep,
56+
ReadableTIFilterDep,
57+
get_auth_manager,
58+
requires_access_dag,
59+
)
5560
from airflow.api_fastapi.logging.decorators import action_logging
5661
from airflow.models.dag_version import DagVersion
5762
from airflow.models.dagrun import DagRun
@@ -155,7 +160,9 @@ def update_hitl_detail(
155160
user_id = str(user_id)
156161
hitl_user = HITLUser(id=user_id, name=user_name)
157162
if hitl_detail_model.assigned_users:
158-
if hitl_user not in hitl_detail_model.assigned_users:
163+
# Convert assigned_users list to set of user IDs for authorization check
164+
assigned_user_ids = {assigned_user["id"] for assigned_user in hitl_detail_model.assigned_users}
165+
if not get_auth_manager().is_authorized_hitl_task(assigned_users=assigned_user_ids, user=user):
159166
log.error("User=%s (id=%s) is not a respondent for the task", user_name, user_id)
160167
raise HTTPException(
161168
status.HTTP_403_FORBIDDEN,

airflow-core/src/airflow/cli/cli_config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,18 @@ def string_lower_type(val):
520520
"Lower values reduce long-running locks but increase the number of batches."
521521
),
522522
)
523+
ARG_DAG_IDS = Arg(
524+
("--dag-ids",),
525+
default=None,
526+
help="Only cleanup data related to the given dag_id",
527+
type=string_list_type,
528+
)
529+
ARG_EXCLUDE_DAG_IDS = Arg(
530+
("--exclude-dag-ids",),
531+
default=None,
532+
help="Avoid cleaning up data related to the given dag_ids",
533+
type=string_list_type,
534+
)
523535

524536
# pool
525537
ARG_POOL_NAME = Arg(("pool",), metavar="NAME", help="Pool name")
@@ -1527,6 +1539,8 @@ class GroupCommand(NamedTuple):
15271539
ARG_YES,
15281540
ARG_DB_SKIP_ARCHIVE,
15291541
ARG_DB_BATCH_SIZE,
1542+
ARG_DAG_IDS,
1543+
ARG_EXCLUDE_DAG_IDS,
15301544
),
15311545
),
15321546
ActionCommand(

0 commit comments

Comments
 (0)