Coverage for /home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/core_api/routes/public/__init__.py: 100%

69 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 14:22 +0000

1# Licensed to the Apache Software Foundation (ASF) under one 

2# or more contributor license agreements. See the NOTICE file 

3# distributed with this work for additional information 

4# regarding copyright ownership. The ASF licenses this file 

5# to you under the Apache License, Version 2.0 (the 

6# "License"); you may not use this file except in compliance 

7# with the License. You may obtain a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, 

12# software distributed under the License is distributed on an 

13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 

14# KIND, either express or implied. See the License for the 

15# specific language governing permissions and limitations 

16# under the License. 

17 

18from __future__ import annotations 

19 

20from fastapi import Depends, status 

21 

22from airflow.api_fastapi.common.router import AirflowRouter 

23from airflow.api_fastapi.core_api.openapi.exceptions import create_openapi_http_exception_doc 

24from airflow.api_fastapi.core_api.routes.public.asset_state_store import asset_state_store_router 

25from airflow.api_fastapi.core_api.routes.public.assets import assets_router 

26from airflow.api_fastapi.core_api.routes.public.auth import auth_router 

27from airflow.api_fastapi.core_api.routes.public.backfills import backfills_router 

28from airflow.api_fastapi.core_api.routes.public.config import config_router 

29from airflow.api_fastapi.core_api.routes.public.connections import connections_router 

30from airflow.api_fastapi.core_api.routes.public.dag_parsing import dag_parsing_router 

31from airflow.api_fastapi.core_api.routes.public.dag_run import dag_run_at_dag_router, dag_run_router 

32from airflow.api_fastapi.core_api.routes.public.dag_sources import dag_sources_router 

33from airflow.api_fastapi.core_api.routes.public.dag_stats import dag_stats_router 

34from airflow.api_fastapi.core_api.routes.public.dag_tags import dag_tags_router 

35from airflow.api_fastapi.core_api.routes.public.dag_versions import dag_versions_router 

36from airflow.api_fastapi.core_api.routes.public.dag_warning import dag_warning_router 

37from airflow.api_fastapi.core_api.routes.public.dags import dags_router 

38from airflow.api_fastapi.core_api.routes.public.event_logs import event_logs_router 

39from airflow.api_fastapi.core_api.routes.public.extra_links import extra_links_router 

40from airflow.api_fastapi.core_api.routes.public.hitl import task_instances_hitl_router 

41from airflow.api_fastapi.core_api.routes.public.import_error import import_error_router 

42from airflow.api_fastapi.core_api.routes.public.job import job_router 

43from airflow.api_fastapi.core_api.routes.public.log import task_instances_log_router 

44from airflow.api_fastapi.core_api.routes.public.monitor import monitor_router 

45from airflow.api_fastapi.core_api.routes.public.plugins import plugins_router 

46from airflow.api_fastapi.core_api.routes.public.pools import pools_router 

47from airflow.api_fastapi.core_api.routes.public.providers import providers_router 

48from airflow.api_fastapi.core_api.routes.public.task_instances import task_instances_router 

49from airflow.api_fastapi.core_api.routes.public.task_state_store import task_state_store_router 

50from airflow.api_fastapi.core_api.routes.public.tasks import tasks_router 

51from airflow.api_fastapi.core_api.routes.public.variables import variables_router 

52from airflow.api_fastapi.core_api.routes.public.version import version_router 

53from airflow.api_fastapi.core_api.routes.public.xcom import xcom_router 

54from airflow.api_fastapi.core_api.security import get_user 

55 

56public_router = AirflowRouter(prefix="/api/v2") 

57 

58# Router-level Depends(get_user) makes authentication the default for every route below. 

59# Individual routes still declare their own GetUserDep / requires_access_* dependencies for 

60# fine-grained authorization; the router-level dependency is the defense-in-depth backstop 

61# that prevents a future route from accidentally being added without an auth check. 

62authenticated_router = AirflowRouter( 

63 dependencies=[Depends(get_user)], 

64 responses=create_openapi_http_exception_doc([status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN]), 

65) 

66 

67 

68authenticated_router.include_router(assets_router) 

69authenticated_router.include_router(backfills_router) 

70authenticated_router.include_router(connections_router) 

71authenticated_router.include_router(dag_run_router) 

72authenticated_router.include_router(dag_run_at_dag_router) 

73authenticated_router.include_router(dag_sources_router) 

74authenticated_router.include_router(dag_stats_router) 

75authenticated_router.include_router(config_router) 

76authenticated_router.include_router(dag_warning_router) 

77authenticated_router.include_router(dags_router) 

78authenticated_router.include_router(event_logs_router) 

79authenticated_router.include_router(extra_links_router) 

80authenticated_router.include_router(import_error_router) 

81authenticated_router.include_router(job_router) 

82authenticated_router.include_router(plugins_router) 

83authenticated_router.include_router(pools_router) 

84authenticated_router.include_router(providers_router) 

85authenticated_router.include_router(asset_state_store_router) 

86authenticated_router.include_router(task_state_store_router) 

87authenticated_router.include_router(xcom_router) 

88authenticated_router.include_router(task_instances_router) 

89authenticated_router.include_router(tasks_router) 

90authenticated_router.include_router(variables_router) 

91authenticated_router.include_router(task_instances_log_router) 

92authenticated_router.include_router(dag_parsing_router) 

93authenticated_router.include_router(dag_tags_router) 

94authenticated_router.include_router(dag_versions_router) 

95authenticated_router.include_router(task_instances_hitl_router) 

96 

97 

98# Include authenticated router in public router 

99public_router.include_router(authenticated_router) 

100 

101# Following routers are not included in common router, for now we don't expect it to have authentication 

102public_router.include_router(monitor_router) 

103public_router.include_router(version_router) 

104public_router.include_router(auth_router)