From 62cdd307cc8b10aa42ae0720a9518d0a2976ff11 Mon Sep 17 00:00:00 2001 From: vincbeck Date: Wed, 19 Jun 2024 09:16:39 -0400 Subject: [PATCH] Use `deprecated_options` to deprecate some webserver related config options --- airflow/configuration.py | 3 ++ .../fab/auth_manager/fab_auth_manager.py | 4 +-- airflow/www/extensions/init_appbuilder.py | 32 ++++--------------- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/airflow/configuration.py b/airflow/configuration.py index 37a12ee070f2c..eb10b538e3234 100644 --- a/airflow/configuration.py +++ b/airflow/configuration.py @@ -390,6 +390,9 @@ def sensitive_config_values(self) -> Set[tuple[str, str]]: # noqa: UP006 "worker_pods_pending_timeout_check_interval", "2.6.0", ), + ("fab", "update_fab_perms"): ("webserver", "update_fab_perms", "2.9.0"), + ("fab", "auth_rate_limited"): ("webserver", "auth_rate_limited", "2.9.0"), + ("fab", "auth_rate_limit"): ("webserver", "auth_rate_limit", "2.9.0"), } # A mapping of new configurations to a list of old configurations for when one configuration diff --git a/airflow/providers/fab/auth_manager/fab_auth_manager.py b/airflow/providers/fab/auth_manager/fab_auth_manager.py index ffd5e5cab5d3e..84c8464dc47ff 100644 --- a/airflow/providers/fab/auth_manager/fab_auth_manager.py +++ b/airflow/providers/fab/auth_manager/fab_auth_manager.py @@ -494,9 +494,7 @@ def _sync_appbuilder_roles(self): # Otherwise, when the name of a view or menu is changed, the framework # will add the new Views and Menus names to the backend, but will not # delete the old ones. - if conf.getboolean( - "fab", "UPDATE_FAB_PERMS", fallback=conf.getboolean("webserver", "UPDATE_FAB_PERMS") - ): + if conf.getboolean("fab", "UPDATE_FAB_PERMS"): self.security_manager.sync_roles() diff --git a/airflow/www/extensions/init_appbuilder.py b/airflow/www/extensions/init_appbuilder.py index 7bb71ba9804fd..4736836a8b828 100644 --- a/airflow/www/extensions/init_appbuilder.py +++ b/airflow/www/extensions/init_appbuilder.py @@ -131,19 +131,9 @@ def __init__( base_template="airflow/main.html", static_folder="static/appbuilder", static_url_path="/appbuilder", - update_perms=conf.getboolean( - "fab", "UPDATE_FAB_PERMS", fallback=conf.getboolean("webserver", "UPDATE_FAB_PERMS") - ), - auth_rate_limited=conf.getboolean( - "fab", - "AUTH_RATE_LIMITED", - fallback=conf.getboolean("webserver", "AUTH_RATE_LIMITED", fallback=True), - ), - auth_rate_limit=conf.get( - "fab", - "AUTH_RATE_LIMIT", - fallback=conf.get("webserver", "AUTH_RATE_LIMIT", fallback="5 per 40 second"), - ), + update_perms=conf.getboolean("fab", "UPDATE_FAB_PERMS"), + auth_rate_limited=conf.getboolean("fab", "AUTH_RATE_LIMITED"), + auth_rate_limit=conf.get("fab", "AUTH_RATE_LIMIT"), ): """ App-builder constructor. @@ -677,17 +667,7 @@ def init_appbuilder(app: Flask) -> AirflowAppBuilder: app=app, session=settings.Session, base_template="airflow/main.html", - update_perms=conf.getboolean( - "fab", "UPDATE_FAB_PERMS", fallback=conf.getboolean("webserver", "UPDATE_FAB_PERMS") - ), - auth_rate_limited=conf.getboolean( - "fab", - "AUTH_RATE_LIMITED", - fallback=conf.getboolean("webserver", "AUTH_RATE_LIMITED", fallback=True), - ), - auth_rate_limit=conf.get( - "fab", - "AUTH_RATE_LIMIT", - fallback=conf.get("webserver", "AUTH_RATE_LIMIT", fallback="5 per 40 second"), - ), + update_perms=conf.getboolean("fab", "UPDATE_FAB_PERMS"), + auth_rate_limited=conf.getboolean("fab", "AUTH_RATE_LIMITED"), + auth_rate_limit=conf.get("fab", "AUTH_RATE_LIMIT"), )