Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Remove Python version from /_synapse/admin/v1/server_version #16380

Merged
merged 13 commits into from
Oct 2, 2023
13 changes: 13 additions & 0 deletions docs/usage/configuration/config_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,19 @@ This setting has the following sub-options:
* `password_reset`: Subject to use when sending a password reset email. Defaults to "[%(server_name)s] Password reset"
* `email_validation`: Subject to use when sending a verification email to assert an address's
ownership. Defaults to "[%(server_name)s] Validate your email"
---
### `hide_python_version`

This option controls whether or not the current Python version of the homeserver is displayed [here](../../admin_api/version_api.md).

The default is False, which means that the homeserver will display the Python version.

**Note:** This option does not affect the Python-related information exposed by [Metrics](#Metrics).

Example configuration:
```yaml
hide_python_version: True
```

Example configuration:

Expand Down
1 change: 1 addition & 0 deletions synapse/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ class ServerConfig(Config):
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
self.server_name = config["server_name"]
self.server_context = config.get("server_context", None)
self.hide_python_version = config.get("hide_python_version", False)

try:
parse_and_validate_server_name(self.server_name)
Expand Down
6 changes: 5 additions & 1 deletion synapse/rest/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ class VersionServlet(RestServlet):
def __init__(self, hs: "HomeServer"):
self.res = {
"server_version": SYNAPSE_VERSION,
"python_version": platform.python_version(),
"python_version": (
platform.python_version()
if not hs.config.server.hide_python_version
else "UNKNOWN"
),
MomentQYC marked this conversation as resolved.
Show resolved Hide resolved
}

def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
Expand Down