This is an automated email from the ASF dual-hosted git repository.

pierrejeambrun pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-0-test by this push:
     new 61d80650744 Move webserver expose_hostname config to fab (#50269) 
(#50605)
61d80650744 is described below

commit 61d80650744252bfddd6837f64a084e4ee58d73e
Author: Pierre Jeambrun <[email protected]>
AuthorDate: Wed May 14 16:57:51 2025 +0200

    Move webserver expose_hostname config to fab (#50269) (#50605)
    
    (cherry picked from commit 7c292141cb69ee37c5b2bd621cae85526b828b03)
---
 airflow-core/src/airflow/cli/commands/config_command.py            | 4 ++++
 airflow-core/src/airflow/config_templates/config.yml               | 7 -------
 airflow-core/src/airflow/configuration.py                          | 1 +
 providers/fab/provider.yaml                                        | 7 +++++++
 providers/fab/src/airflow/providers/fab/get_provider_info.py       | 7 +++++++
 providers/fab/src/airflow/providers/fab/www/auth.py                | 4 ++--
 .../src/airflow/providers/fab/www/extensions/init_jinja_globals.py | 2 +-
 7 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/airflow-core/src/airflow/cli/commands/config_command.py 
b/airflow-core/src/airflow/cli/commands/config_command.py
index 843adcd87db..bedf7681e0d 100644
--- a/airflow-core/src/airflow/cli/commands/config_command.py
+++ b/airflow-core/src/airflow/cli/commands/config_command.py
@@ -383,6 +383,10 @@ CONFIGS_CHANGES = [
         config=ConfigParameter("webserver", "access_denied_message"),
         renamed_to=ConfigParameter("fab", "access_denied_message"),
     ),
+    ConfigChange(
+        config=ConfigParameter("webserver", "expose_hostname"),
+        renamed_to=ConfigParameter("fab", "expose_hostname"),
+    ),
     ConfigChange(
         config=ConfigParameter("webserver", "base_url"),
         renamed_to=ConfigParameter("api", "base_url"),
diff --git a/airflow-core/src/airflow/config_templates/config.yml 
b/airflow-core/src/airflow/config_templates/config.yml
index f88d0f02e5f..122b67174e5 100644
--- a/airflow-core/src/airflow/config_templates/config.yml
+++ b/airflow-core/src/airflow/config_templates/config.yml
@@ -1741,13 +1741,6 @@ webserver:
       sensitive: true
       example: ~
       default: "{SECRET_KEY}"
-    expose_hostname:
-      description: |
-        Expose hostname in the web server
-      version_added: 1.10.8
-      type: string
-      example: ~
-      default: "False"
     grid_view_sorting_order:
       description: |
         Sorting order in grid view. Valid values are: ``topological``, 
``hierarchical_alphabetical``
diff --git a/airflow-core/src/airflow/configuration.py 
b/airflow-core/src/airflow/configuration.py
index 385b87e5f92..592a060307d 100644
--- a/airflow-core/src/airflow/configuration.py
+++ b/airflow-core/src/airflow/configuration.py
@@ -357,6 +357,7 @@ class AirflowConfigParser(ConfigParser):
         ("triggerer", "capacity"): ("triggerer", "default_capacity", "3.0"),
         ("api", "expose_config"): ("webserver", "expose_config", "3.0.1"),
         ("fab", "access_denied_message"): ("webserver", 
"access_denied_message", "3.0.2"),
+        ("fab", "expose_hostname"): ("webserver", "expose_hostname", "3.0.2"),
     }
 
     # A mapping of new section -> (old section, since_version).
diff --git a/providers/fab/provider.yaml b/providers/fab/provider.yaml
index b34d7264ac7..9c7d63f76a6 100644
--- a/providers/fab/provider.yaml
+++ b/providers/fab/provider.yaml
@@ -64,6 +64,13 @@ config:
         type: string
         example: ~
         default: "Access is Denied"
+      expose_hostname:
+        description: |
+          Expose hostname in the web server
+        version_added: 2.0.3
+        type: string
+        example: ~
+        default: "False"
       auth_rate_limited:
         description: |
           Boolean for enabling rate limiting on authentication endpoints.
diff --git a/providers/fab/src/airflow/providers/fab/get_provider_info.py 
b/providers/fab/src/airflow/providers/fab/get_provider_info.py
index 4baf5b88011..a811deb5cec 100644
--- a/providers/fab/src/airflow/providers/fab/get_provider_info.py
+++ b/providers/fab/src/airflow/providers/fab/get_provider_info.py
@@ -37,6 +37,13 @@ def get_provider_info():
                         "example": None,
                         "default": "Access is Denied",
                     },
+                    "expose_hostname": {
+                        "description": "Expose hostname in the web server\n",
+                        "version_added": "2.0.3",
+                        "type": "string",
+                        "example": None,
+                        "default": "False",
+                    },
                     "auth_rate_limited": {
                         "description": "Boolean for enabling rate limiting on 
authentication endpoints.\n",
                         "version_added": "1.0.2",
diff --git a/providers/fab/src/airflow/providers/fab/www/auth.py 
b/providers/fab/src/airflow/providers/fab/www/auth.py
index 204bab48040..a01ab8c9e1f 100644
--- a/providers/fab/src/airflow/providers/fab/www/auth.py
+++ b/providers/fab/src/airflow/providers/fab/www/auth.py
@@ -145,7 +145,7 @@ def _has_access(*, is_authorized: bool, func: Callable, 
args, kwargs):
         return (
             render_template(
                 "airflow/no_roles_permissions.html",
-                hostname=get_hostname() if conf.getboolean("webserver", 
"EXPOSE_HOSTNAME") else "",
+                hostname=get_hostname() if conf.getboolean("fab", 
"EXPOSE_HOSTNAME") else "",
                 logout_url=get_fab_auth_manager().get_url_logout(),
             ),
             403,
@@ -217,7 +217,7 @@ def has_access_dag(method: ResourceMethod, access_entity: 
DagAccessEntity | None
                 return (
                     render_template(
                         "airflow/no_roles_permissions.html",
-                        hostname=get_hostname() if 
conf.getboolean("webserver", "EXPOSE_HOSTNAME") else "",
+                        hostname=get_hostname() if conf.getboolean("fab", 
"EXPOSE_HOSTNAME") else "",
                         logout_url=get_auth_manager().get_url_logout(),
                     ),
                     403,
diff --git 
a/providers/fab/src/airflow/providers/fab/www/extensions/init_jinja_globals.py 
b/providers/fab/src/airflow/providers/fab/www/extensions/init_jinja_globals.py
index 5929a40d8f5..35aa5c71413 100644
--- 
a/providers/fab/src/airflow/providers/fab/www/extensions/init_jinja_globals.py
+++ 
b/providers/fab/src/airflow/providers/fab/www/extensions/init_jinja_globals.py
@@ -37,7 +37,7 @@ def init_jinja_globals(app, enable_plugins: bool):
     elif server_timezone == "utc":
         server_timezone = "UTC"
 
-    expose_hostname = conf.getboolean("webserver", "EXPOSE_HOSTNAME")
+    expose_hostname = conf.getboolean("fab", "EXPOSE_HOSTNAME")
     hostname = get_hostname() if expose_hostname else "redact"
 
     try:

Reply via email to