Skip to content

Move webserver expose_hostname config to fab #50269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions airflow-core/src/airflow/cli/commands/config_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ def message(self) -> str | None:
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"),
Expand Down
7 changes: 0 additions & 7 deletions airflow-core/src/airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1707,13 +1707,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``
Expand Down
1 change: 1 addition & 0 deletions airflow-core/src/airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def sensitive_config_values(self) -> set[tuple[str, str]]:
("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).
Expand Down
9 changes: 8 additions & 1 deletion providers/fab/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ config:
access_denied_message:
description: |
The message displayed when a user attempts to execute actions beyond their authorised privileges.
version_added: 2.0.2
version_added: 2.0.3
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ def get_provider_info():
"options": {
"access_denied_message": {
"description": "The message displayed when a user attempts to execute actions beyond their authorised privileges.\n",
"version_added": "2.0.2",
"version_added": "2.0.3",
"type": "string",
"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",
Expand Down
4 changes: 2 additions & 2 deletions providers/fab/src/airflow/providers/fab/www/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -217,7 +217,7 @@ def decorated(*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_auth_manager().get_url_logout(),
),
403,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down