From a32eec757b54c4029a025bdbf2a596c5fa7f71a3 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Mon, 17 Mar 2025 17:09:56 +0200 Subject: [PATCH] Don't host `/.well-known/element/element.json` file when Element Call is enabled Various old guides mention this, but it seems like neither Element Web, nor Element Desktop make use of it. Element Web & Element Desktop use their own `config.json` configuration to figure out where Element Call is. --- group_vars/matrix_servers | 3 - .../matrix-static-files/defaults/main.yml | 65 ------------------- .../matrix-static-files/tasks/install.yml | 17 ++--- .../tasks/validate_config.yml | 3 - .../matrix-static-files/templates/labels.j2 | 41 ------------ .../.well-known/element/element.json.j2 | 7 -- .../element/element.json.j2.license | 4 -- 7 files changed, 6 insertions(+), 134 deletions(-) delete mode 100644 roles/custom/matrix-static-files/templates/public/.well-known/element/element.json.j2 delete mode 100644 roles/custom/matrix-static-files/templates/public/.well-known/element/element.json.j2.license diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 34bbc0da2..d1a51123b 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -6118,7 +6118,6 @@ matrix_static_files_container_labels_traefik_entrypoints: "{{ traefik_entrypoint matrix_static_files_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_hostname: "{{ matrix_server_fqn_matrix }}" -matrix_static_files_container_labels_well_known_element_endpoint_traefik_hostname: "{{ matrix_server_fqn_matrix }}" # Base domain serving is not enabled by default (see `matrix_static_files_container_labels_base_domain_enabled`), # but we pass the hostname, so that enabling it is easy. @@ -6153,8 +6152,6 @@ matrix_static_files_file_matrix_client_property_org_matrix_msc4143_rtc_foci_auto matrix_static_files_file_matrix_server_property_m_server: "{{ matrix_server_fqn_matrix_federation }}:{{ matrix_federation_public_port }}" -matrix_static_files_file_element_element_json_property_call_widget_url: "{{ matrix_element_call_public_url if matrix_element_call_enabled else '' }}" - matrix_static_files_scheme: "{{ 'https' if matrix_playbook_ssl_enabled else 'http' }}" matrix_static_files_self_check_hostname_matrix: "{{ matrix_server_fqn_matrix }}" diff --git a/roles/custom/matrix-static-files/defaults/main.yml b/roles/custom/matrix-static-files/defaults/main.yml index cbd8ab79d..de0a568c2 100644 --- a/roles/custom/matrix-static-files/defaults/main.yml +++ b/roles/custom/matrix-static-files/defaults/main.yml @@ -72,21 +72,6 @@ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_tls_cert matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_enabled: true matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_minResponseBodyBytes: 100 # noqa var-naming -# Controls whether labels will be added that expose the `/.well-known/element` endpoint on the Matrix domain. -matrix_static_files_container_labels_well_known_element_endpoint_enabled: true -matrix_static_files_container_labels_well_known_element_endpoint_traefik_hostname: '' -matrix_static_files_container_labels_well_known_element_endpoint_traefik_path_prefix: /.well-known/element -matrix_static_files_container_labels_well_known_element_endpoint_traefik_rule: "Host(`{{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_hostname }}`) && PathPrefix(`{{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_path_prefix }}`)" -matrix_static_files_container_labels_well_known_element_endpoint_traefik_priority: 0 -matrix_static_files_container_labels_well_known_element_endpoint_traefik_entrypoints: "{{ matrix_static_files_container_labels_traefik_entrypoints }}" -matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls: "{{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_entrypoints != 'web' }}" -matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls_certResolver: "{{ matrix_static_files_container_labels_traefik_tls_certResolver }}" # noqa var-naming -# Controls whether the compress middleware (https://doc.traefik.io/traefik/middlewares/http/compress/) will be enabled for this router. -# The web-server only compresses known file types and our /.well-known/matrix/* files have no file extension. -# As such, they are not being compressed there and we compress them at the Traefik level. -matrix_static_files_container_labels_well_known_element_endpoint_middleware_compress_enabled: true -matrix_static_files_container_labels_well_known_element_endpoint_middleware_compress_minResponseBodyBytes: 100 # noqa var-naming - # Controls whether labels will be added that serve the base domain. # # This is similar to `matrix_static_files_container_labels_well_known_matrix_endpoint_*`, but does more. @@ -384,56 +369,6 @@ matrix_static_files_file_matrix_support_configuration: "{{ matrix_static_files_f ######################################################################## -######################################################################## -# # -# Related to /.well-known/element/element.json # -# # -######################################################################## - -# Controls whether a `/.well-known/element/element.json` file is generated and used at all. -matrix_static_files_file_element_element_json_enabled: true - -# Controls the call.widget_url property in the /.well-known/element/element.json file -matrix_static_files_file_element_element_json_property_call_widget_url: '' - -# Default /.well-known/element/element.json configuration template which covers the generic use case. -# You can customize it by controlling the various variables inside it. -# -# For a more advanced customization, you can extend the default (see `matrix_static_files_file_matrix_support_configuration_extension_json`) -# or completely replace this variable with your own template. -matrix_static_files_file_element_element_json_configuration_json: "{{ lookup('template', 'templates/public/.well-known/element/element.json.j2') }}" - -# Your custom JSON configuration for /.well-known/element/element.json should go to `matrix_static_files_file_element_element_json_configuration_extension_json`. -# This configuration extends the default starting configuration (`matrix_static_files_file_matrix_support_configuration_extension_json`). -# -# You can override individual variables from the default configuration, or introduce new ones. -# -# If you need something more special, you can take full control by -# completely redefining `matrix_static_files_file_matrix_support_configuration_json`. -# -# Example configuration extension follows: -# -# matrix_static_files_file_element_element_json_configuration_extension_json: | -# { -# "call": { -# "url": "value" -# } -# } -matrix_static_files_file_element_element_json_configuration_extension_json: '{}' - -matrix_static_files_file_element_element_json_configuration_extension: "{{ matrix_static_files_file_element_element_json_configuration_extension_json | from_json if matrix_static_files_file_element_element_json_configuration_extension_json | from_json is mapping else {} }}" - -# Holds the final /.well-known/matrix/support configuration (a combination of the default and its extension). -# You most likely don't need to touch this variable. Instead, see `matrix_static_files_file_element_element_json_configuration_json` or `matrix_static_files_file_element_element_json_configuration_extension_json`. -matrix_static_files_file_element_element_json_configuration: "{{ matrix_static_files_file_element_element_json_configuration_json | combine(matrix_static_files_file_element_element_json_configuration_extension, recursive=True) }}" - -######################################################################## -# # -# /Related to /.well-known/element/element.json # -# # -######################################################################## - - ######################################################################## # # # Related to index.html # diff --git a/roles/custom/matrix-static-files/tasks/install.yml b/roles/custom/matrix-static-files/tasks/install.yml index 5b8609011..dd467a38d 100644 --- a/roles/custom/matrix-static-files/tasks/install.yml +++ b/roles/custom/matrix-static-files/tasks/install.yml @@ -18,9 +18,14 @@ - {path: "{{ matrix_static_files_public_path }}", when: true} - {path: "{{ matrix_static_files_public_well_known_path }}", when: true} - {path: "{{ matrix_static_files_public_well_known_matrix_path }}", when: true} - - {path: "{{ matrix_static_files_public_well_known_element_path }}", when: true} when: "item.when | bool" +# This is not necessary anymore, so we're cleaning it up. +- name: Ensure matrix-static-files element path doesn't exist + ansible.builtin.file: + path: "{{ matrix_static_files_public_well_known_element_path }}" + state: absent + - name: Ensure matrix-static-files is configured ansible.builtin.template: src: "{{ item.src }}" @@ -59,10 +64,6 @@ dest: "{{ matrix_static_files_public_well_known_matrix_path }}/support" when: "{{ matrix_static_files_file_matrix_support_enabled }}" - - content: "{{ matrix_static_files_file_element_element_json_configuration | to_nice_json }}" - dest: "{{ matrix_static_files_public_well_known_element_path }}/element.json" - when: "{{ matrix_static_files_file_element_element_json_enabled }}" - # This one will not be deleted if `matrix_static_files_file_index_html_enabled` flips to `false`. # See the comment for `matrix_static_files_file_index_html_enabled` to learn why. - content: "{{ matrix_static_files_file_index_html_template }}" @@ -81,12 +82,6 @@ state: absent when: "not matrix_static_files_file_matrix_support_enabled | bool" -- name: Ensure /.well-known/element/element.json file deleted if not enabled - ansible.builtin.file: - path: "{{ matrix_static_files_public_well_known_element_path }}/element.json" - state: absent - when: "not matrix_static_files_file_element_element_json_enabled | bool" - - name: Ensure matrix-static-files container image is pulled community.docker.docker_image: name: "{{ matrix_static_files_container_image }}" diff --git a/roles/custom/matrix-static-files/tasks/validate_config.yml b/roles/custom/matrix-static-files/tasks/validate_config.yml index b76b8201e..2697fa654 100644 --- a/roles/custom/matrix-static-files/tasks/validate_config.yml +++ b/roles/custom/matrix-static-files/tasks/validate_config.yml @@ -13,9 +13,6 @@ - {'name': 'matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_hostname', when: "{{ matrix_static_files_container_labels_well_known_matrix_endpoint_enabled }}"} - {'name': 'matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_path_prefix', when: "{{ matrix_static_files_container_labels_well_known_matrix_endpoint_enabled }}"} - - {'name': 'matrix_static_files_container_labels_well_known_element_endpoint_traefik_hostname', when: "{{ matrix_static_files_container_labels_well_known_element_endpoint_enabled }}"} - - {'name': 'matrix_static_files_container_labels_well_known_element_endpoint_traefik_path_prefix', when: "{{ matrix_static_files_container_labels_well_known_element_endpoint_enabled }}"} - - {'name': 'matrix_static_files_container_labels_base_domain_traefik_hostname', when: "{{ matrix_static_files_container_labels_base_domain_enabled }}"} - {'name': 'matrix_static_files_container_labels_base_domain_traefik_path_prefix', when: "{{ matrix_static_files_container_labels_base_domain_enabled }}"} diff --git a/roles/custom/matrix-static-files/templates/labels.j2 b/roles/custom/matrix-static-files/templates/labels.j2 index 26bd34036..9c502c694 100644 --- a/roles/custom/matrix-static-files/templates/labels.j2 +++ b/roles/custom/matrix-static-files/templates/labels.j2 @@ -56,47 +56,6 @@ traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-matrix.tls. {% endif %} -{% if matrix_static_files_container_labels_well_known_element_endpoint_enabled %} -############################################################ -# # -# Related to /.well-known/element on the Matrix domain # -# # -############################################################ - -{% set well_known_element_endpoint_middlewares = [] %} - -{% if matrix_static_files_container_labels_well_known_element_endpoint_middleware_compress_enabled %} -traefik.http.middlewares.{{ matrix_static_files_identifier }}-well-known-element-compress.compress=true -traefik.http.middlewares.{{ matrix_static_files_identifier }}-well-known-element-compress.compress.minResponseBodyBytes={{ matrix_static_files_container_labels_well_known_element_endpoint_middleware_compress_minResponseBodyBytes }} -{% set well_known_element_endpoint_middlewares = well_known_element_endpoint_middlewares + [matrix_static_files_identifier + '-well-known-element-compress'] %} -{% endif %} - -traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.rule={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_rule }} - -{% if well_known_element_endpoint_middlewares | length > 0 %} -traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.middlewares={{ well_known_element_endpoint_middlewares | join(',') }} -{% endif %} - -{% if matrix_static_files_container_labels_well_known_element_endpoint_traefik_priority | int > 0 %} -traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.priority={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_priority }} -{% endif %} - -traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.service={{ matrix_static_files_identifier }} -traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.entrypoints={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_entrypoints }} -traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.tls={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls | to_json }} - -{% if matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls %} -traefik.http.routers.{{ matrix_static_files_identifier }}-well-known-element.tls.certResolver={{ matrix_static_files_container_labels_well_known_element_endpoint_traefik_tls_certResolver }} -{% endif %} - -############################################################ -# # -# /Related to /.well-known/element on the Matrix domain # -# # -############################################################ -{% endif %} - - {% if matrix_static_files_container_labels_base_domain_enabled %} ############################################################ # # diff --git a/roles/custom/matrix-static-files/templates/public/.well-known/element/element.json.j2 b/roles/custom/matrix-static-files/templates/public/.well-known/element/element.json.j2 deleted file mode 100644 index 68d13f098..000000000 --- a/roles/custom/matrix-static-files/templates/public/.well-known/element/element.json.j2 +++ /dev/null @@ -1,7 +0,0 @@ -{ - {% if matrix_static_files_file_element_element_json_property_call_widget_url %} - "call": { - "widget_url": {{ matrix_static_files_file_element_element_json_property_call_widget_url | to_json }} - } - {% endif %} -} diff --git a/roles/custom/matrix-static-files/templates/public/.well-known/element/element.json.j2.license b/roles/custom/matrix-static-files/templates/public/.well-known/element/element.json.j2.license deleted file mode 100644 index 3d67f3cc5..000000000 --- a/roles/custom/matrix-static-files/templates/public/.well-known/element/element.json.j2.license +++ /dev/null @@ -1,4 +0,0 @@ -SPDX-FileCopyrightText: 2024 wjbeckett -SPDX-FileCopyrightText: 2024 Slavi Pantaleev - -SPDX-License-Identifier: AGPL-3.0-or-later