Skip to content

Commit 31c7c96

Browse files
Move webserver expose config to api section (#50209)
1 parent 82c65f8 commit 31c7c96

File tree

11 files changed

+32
-26
lines changed

11 files changed

+32
-26
lines changed

Dockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ function start_api_server_with_examples(){
11451145
return
11461146
fi
11471147
export AIRFLOW__CORE__LOAD_EXAMPLES=True
1148-
export AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True
1148+
export AIRFLOW__API__EXPOSE_CONFIG=True
11491149
airflow dags reserialize
11501150
echo "Example dags parsing finished"
11511151
if airflow config get-value core auth_manager | grep -q "FabAuthManager"; then

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@
7070

7171
def _check_expose_config() -> bool:
7272
display_sensitive: bool | None = None
73-
if conf.get("webserver", "expose_config").lower() == "non-sensitive-only":
73+
if conf.get("api", "expose_config").lower() == "non-sensitive-only":
7474
expose_config = True
7575
display_sensitive = False
7676
else:
77-
expose_config = conf.getboolean("webserver", "expose_config")
77+
expose_config = conf.getboolean("api", "expose_config")
7878
display_sensitive = True
7979

8080
if not expose_config:

airflow-core/src/airflow/cli/commands/config_command.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ def message(self) -> str | None:
495495
renamed_to=ConfigParameter("fab", "proxy_fix_x_prefix"),
496496
breaking=True,
497497
),
498+
ConfigChange(
499+
config=ConfigParameter("webserver", "expose_config"),
500+
renamed_to=ConfigParameter("api", "expose_config"),
501+
),
498502
ConfigChange(
499503
config=ConfigParameter("webserver", "cookie_secure"),
500504
was_deprecated=False,

airflow-core/src/airflow/config_templates/config.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,15 @@ secrets:
12841284
api:
12851285
description: ~
12861286
options:
1287+
expose_config:
1288+
description: |
1289+
Expose the configuration file in the web server. Set to ``non-sensitive-only`` to show all values
1290+
except those that have security implications. ``True`` shows all values. ``False`` hides the
1291+
configuration completely.
1292+
version_added: ~
1293+
type: string
1294+
example: ~
1295+
default: "False"
12871296
base_url:
12881297
description: |
12891298
The base url of the API server. Airflow cannot guess what domain or CNAME you are using.
@@ -1705,15 +1714,6 @@ webserver:
17051714
sensitive: true
17061715
example: ~
17071716
default: "{SECRET_KEY}"
1708-
expose_config:
1709-
description: |
1710-
Expose the configuration file in the web server. Set to ``non-sensitive-only`` to show all values
1711-
except those that have security implications. ``True`` shows all values. ``False`` hides the
1712-
configuration completely.
1713-
version_added: ~
1714-
type: string
1715-
example: ~
1716-
default: "False"
17171717
expose_hostname:
17181718
description: |
17191719
Expose hostname in the web server

airflow-core/src/airflow/configuration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ def sensitive_config_values(self) -> set[tuple[str, str]]:
355355
("api", "ssl_key"): ("webserver", "web_server_ssl_key", "3.0"),
356356
("api", "access_logfile"): ("webserver", "access_logfile", "3.0"),
357357
("triggerer", "capacity"): ("triggerer", "default_capacity", "3.0"),
358+
("api", "expose_config"): ("webserver", "expose_config", "3.0.1"),
358359
}
359360

360361
# A mapping of new section -> (old section, since_version).
@@ -1294,7 +1295,7 @@ def gettimedelta(
12941295

12951296
def read(
12961297
self,
1297-
filenames: (str | bytes | os.PathLike | Iterable[str | bytes | os.PathLike]),
1298+
filenames: str | bytes | os.PathLike | Iterable[str | bytes | os.PathLike],
12981299
encoding=None,
12991300
):
13001301
super().read(filenames=filenames, encoding=encoding)

airflow-core/tests/unit/api_fastapi/auth/managers/simple/test_middleware.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def all_access_test_client():
3232
with conf_vars(
3333
{
3434
("core", "simple_auth_manager_all_admins"): "true",
35-
("webserver", "expose_config"): "true",
35+
("api", "expose_config"): "true",
3636
}
3737
):
3838
app = create_app()
@@ -56,6 +56,7 @@ def all_access_test_client():
5656
)
5757
def test_all_endpoints_without_auth_header(all_access_test_client, method, path):
5858
response = all_access_test_client.request(method, path)
59-
assert response.status_code not in {401, 403}, (
60-
f"Unexpected status code {response.status_code} for {method} {path}"
61-
)
59+
assert response.status_code not in {
60+
401,
61+
403,
62+
}, f"Unexpected status code {response.status_code} for {method} {path}"

airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@
7777
(SECTION_SMTP, OPTION_KEY_SMTP_MAIL_FROM): OPTION_VALUE_SMTP_MAIL_FROM,
7878
}
7979

80-
AIRFLOW_CONFIG_ENABLE_EXPOSE_CONFIG = {("webserver", "expose_config"): "True"}
81-
AIRFLOW_CONFIG_DISABLE_EXPOSE_CONFIG = {("webserver", "expose_config"): "False"}
82-
AIRFLOW_CONFIG_NON_SENSITIVE_ONLY_CONFIG = {("webserver", "expose_config"): "non-sensitive-only"}
80+
AIRFLOW_CONFIG_ENABLE_EXPOSE_CONFIG = {("api", "expose_config"): "True"}
81+
AIRFLOW_CONFIG_DISABLE_EXPOSE_CONFIG = {("api", "expose_config"): "False"}
82+
AIRFLOW_CONFIG_NON_SENSITIVE_ONLY_CONFIG = {("api", "expose_config"): "non-sensitive-only"}
8383
FORBIDDEN_RESPONSE = {
8484
"detail": "Your Airflow administrator chose not to expose the configuration, most likely for security reasons."
8585
}

chart/docs/airflow-configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ allow webserver users to view the config from within the UI:
2828
.. code-block:: yaml
2929
3030
config:
31-
webserver:
31+
api:
3232
expose_config: 'True' # by default this is 'False'
3333
3434
Generally speaking, it is useful to familiarize oneself with the Airflow

clients/python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,11 @@ You can also set it by env variable: `export AIRFLOW__CORE__LOAD_EXAMPLES=True`
555555
In the `[webserver]` section of your `airflow.cfg` set:
556556

557557
```ini
558-
[webserver]
558+
[api]
559559
expose_config = True
560560
```
561561

562-
You can also set it by env variable: `export AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True`
562+
You can also set it by env variable: `export AIRFLOW__API__EXPOSE_CONFIG=True`
563563

564564
* Configure your host/ip/user/password in the `test_python_client.py` file
565565

dev/README_RELEASE_PYTHON_CLIENT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ and allows you to test the client in a real environment.
478478

479479
```shell
480480
export AIRFLOW__API__AUTH_BACKENDS=airflow.providers.fab.auth_manager.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
481-
export AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True
481+
export AIRFLOW__API__EXPOSE_CONFIG=True
482482
```
483483

484484

@@ -487,7 +487,7 @@ or `http://localhost:28080` from the host) and you should be able to access the
487487
with `admin`/`admin` credentials. The `http://localhost:8080` and `admin`/`admin` credentials are
488488
default in the `clients/python/test_python_client.py` test.
489489

490-
The ``AIRFLOW__WEBSERVER__EXPOSE_CONFIG`` is optional - the script will also succeed when
490+
The ``AIRFLOW__API__EXPOSE_CONFIG`` is optional - the script will also succeed when
491491
(default setting) exposing configuration is disabled.
492492

493493
2. Start Airflow in Breeze with example dags enabled:

0 commit comments

Comments
 (0)