jason810496 commented on code in PR #52408:
URL: https://github.com/apache/airflow/pull/52408#discussion_r2173781417
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/config.py:
##########
@@ -46,17 +48,29 @@
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]),
dependencies=[Depends(requires_authenticated())],
)
-def get_configs() -> ConfigResponse:
+async def get_configs(user: GetUserDep) -> ConfigResponse:
"""Get configs for UI."""
config = {key: conf.get("api", key) for key in API_CONFIG_KEYS}
task_log_reader = TaskLogReader()
+ plugins_manager.initialize_ui_plugins()
+
+ auth_manager = get_auth_manager()
+ authorized_plugins = []
+ if plugins_manager.external_views:
+ for view in plugins_manager.external_views:
+ if auth_manager.is_authorized_custom_view(method="GET",
resource_name=view["name"], user=user):
+ authorized_plugins.append(view)
Review Comment:
Do we need to doc the
https://github.com/apache/airflow/pull/51714#pullrequestreview-2953471562
comment here to describe the logic ?
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_config.py:
##########
@@ -20,7 +20,7 @@
from tests_common.test_utils.config import conf_vars
-pytestmark = pytest.mark.db_test
+pytestmark = [pytest.mark.db_test, pytest.mark.mock_plugin_manager(plugins=[])]
Review Comment:
How about we don't mock the plugin manager return an empty list. Let's make
the `external_views` return some views that belongs to `nav` and some are not
belongs to `nav` to ensure the implementaion in router.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/config.py:
##########
@@ -46,17 +48,29 @@
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]),
dependencies=[Depends(requires_authenticated())],
)
-def get_configs() -> ConfigResponse:
+async def get_configs(user: GetUserDep) -> ConfigResponse:
Review Comment:
Why do we need to change this router to `async` ?
--
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]