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

Commit 5639759

Browse files
authored
Centralise the custom template directory (#10596)
Several configuration sections are using separate settings for custom template directories, which can be confusing. This PR adds a new top-level configuration for a custom template directory which is then used for every module. The only exception is the consent templates, since the consent template directory require a specific hierarchy, so it's probably better that it stays separate from everything else.
1 parent c4cf0c0 commit 5639759

File tree

12 files changed

+342
-418
lines changed

12 files changed

+342
-418
lines changed

changelog.d/10596.removal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The `template_dir` configuration settings in the `sso`, `account_validity` and `email` sections of the configuration file are now deprecated in favour of the global `templates.custom_template_directory` setting. See the [upgrade notes](https://matrix-org.github.io/synapse/latest/upgrade.html) for more information.

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- [Homeserver Sample Config File](usage/configuration/homeserver_sample_config.md)
2222
- [Logging Sample Config File](usage/configuration/logging_sample_config.md)
2323
- [Structured Logging](structured_logging.md)
24+
- [Templates](templates.md)
2425
- [User Authentication](usage/configuration/user_authentication/README.md)
2526
- [Single-Sign On]()
2627
- [OpenID Connect](openid.md)

docs/sample_config.yaml

Lines changed: 19 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,19 @@ retention:
565565
#
566566
#next_link_domain_whitelist: ["matrix.org"]
567567

568+
# Templates to use when generating email or HTML page contents.
569+
#
570+
templates:
571+
# Directory in which Synapse will try to find template files to use to generate
572+
# email or HTML page contents.
573+
# If not set, or a file is not found within the template directory, a default
574+
# template from within the Synapse package will be used.
575+
#
576+
# See https://matrix-org.github.io/synapse/latest/templates.html for more
577+
# information about using custom templates.
578+
#
579+
#custom_template_directory: /path/to/custom/templates/
580+
568581

569582
## TLS ##
570583

@@ -1895,6 +1908,9 @@ cas_config:
18951908
# Additional settings to use with single-sign on systems such as OpenID Connect,
18961909
# SAML2 and CAS.
18971910
#
1911+
# Server admins can configure custom templates for pages related to SSO. See
1912+
# https://matrix-org.github.io/synapse/latest/templates.html for more information.
1913+
#
18981914
sso:
18991915
# A list of client URLs which are whitelisted so that the user does not
19001916
# have to confirm giving access to their account to the URL. Any client
@@ -1927,169 +1943,6 @@ sso:
19271943
#
19281944
#update_profile_information: true
19291945

1930-
# Directory in which Synapse will try to find the template files below.
1931-
# If not set, or the files named below are not found within the template
1932-
# directory, default templates from within the Synapse package will be used.
1933-
#
1934-
# Synapse will look for the following templates in this directory:
1935-
#
1936-
# * HTML page to prompt the user to choose an Identity Provider during
1937-
# login: 'sso_login_idp_picker.html'.
1938-
#
1939-
# This is only used if multiple SSO Identity Providers are configured.
1940-
#
1941-
# When rendering, this template is given the following variables:
1942-
# * redirect_url: the URL that the user will be redirected to after
1943-
# login.
1944-
#
1945-
# * server_name: the homeserver's name.
1946-
#
1947-
# * providers: a list of available Identity Providers. Each element is
1948-
# an object with the following attributes:
1949-
#
1950-
# * idp_id: unique identifier for the IdP
1951-
# * idp_name: user-facing name for the IdP
1952-
# * idp_icon: if specified in the IdP config, an MXC URI for an icon
1953-
# for the IdP
1954-
# * idp_brand: if specified in the IdP config, a textual identifier
1955-
# for the brand of the IdP
1956-
#
1957-
# The rendered HTML page should contain a form which submits its results
1958-
# back as a GET request, with the following query parameters:
1959-
#
1960-
# * redirectUrl: the client redirect URI (ie, the `redirect_url` passed
1961-
# to the template)
1962-
#
1963-
# * idp: the 'idp_id' of the chosen IDP.
1964-
#
1965-
# * HTML page to prompt new users to enter a userid and confirm other
1966-
# details: 'sso_auth_account_details.html'. This is only shown if the
1967-
# SSO implementation (with any user_mapping_provider) does not return
1968-
# a localpart.
1969-
#
1970-
# When rendering, this template is given the following variables:
1971-
#
1972-
# * server_name: the homeserver's name.
1973-
#
1974-
# * idp: details of the SSO Identity Provider that the user logged in
1975-
# with: an object with the following attributes:
1976-
#
1977-
# * idp_id: unique identifier for the IdP
1978-
# * idp_name: user-facing name for the IdP
1979-
# * idp_icon: if specified in the IdP config, an MXC URI for an icon
1980-
# for the IdP
1981-
# * idp_brand: if specified in the IdP config, a textual identifier
1982-
# for the brand of the IdP
1983-
#
1984-
# * user_attributes: an object containing details about the user that
1985-
# we received from the IdP. May have the following attributes:
1986-
#
1987-
# * display_name: the user's display_name
1988-
# * emails: a list of email addresses
1989-
#
1990-
# The template should render a form which submits the following fields:
1991-
#
1992-
# * username: the localpart of the user's chosen user id
1993-
#
1994-
# * HTML page allowing the user to consent to the server's terms and
1995-
# conditions. This is only shown for new users, and only if
1996-
# `user_consent.require_at_registration` is set.
1997-
#
1998-
# When rendering, this template is given the following variables:
1999-
#
2000-
# * server_name: the homeserver's name.
2001-
#
2002-
# * user_id: the user's matrix proposed ID.
2003-
#
2004-
# * user_profile.display_name: the user's proposed display name, if any.
2005-
#
2006-
# * consent_version: the version of the terms that the user will be
2007-
# shown
2008-
#
2009-
# * terms_url: a link to the page showing the terms.
2010-
#
2011-
# The template should render a form which submits the following fields:
2012-
#
2013-
# * accepted_version: the version of the terms accepted by the user
2014-
# (ie, 'consent_version' from the input variables).
2015-
#
2016-
# * HTML page for a confirmation step before redirecting back to the client
2017-
# with the login token: 'sso_redirect_confirm.html'.
2018-
#
2019-
# When rendering, this template is given the following variables:
2020-
#
2021-
# * redirect_url: the URL the user is about to be redirected to.
2022-
#
2023-
# * display_url: the same as `redirect_url`, but with the query
2024-
# parameters stripped. The intention is to have a
2025-
# human-readable URL to show to users, not to use it as
2026-
# the final address to redirect to.
2027-
#
2028-
# * server_name: the homeserver's name.
2029-
#
2030-
# * new_user: a boolean indicating whether this is the user's first time
2031-
# logging in.
2032-
#
2033-
# * user_id: the user's matrix ID.
2034-
#
2035-
# * user_profile.avatar_url: an MXC URI for the user's avatar, if any.
2036-
# None if the user has not set an avatar.
2037-
#
2038-
# * user_profile.display_name: the user's display name. None if the user
2039-
# has not set a display name.
2040-
#
2041-
# * HTML page which notifies the user that they are authenticating to confirm
2042-
# an operation on their account during the user interactive authentication
2043-
# process: 'sso_auth_confirm.html'.
2044-
#
2045-
# When rendering, this template is given the following variables:
2046-
# * redirect_url: the URL the user is about to be redirected to.
2047-
#
2048-
# * description: the operation which the user is being asked to confirm
2049-
#
2050-
# * idp: details of the Identity Provider that we will use to confirm
2051-
# the user's identity: an object with the following attributes:
2052-
#
2053-
# * idp_id: unique identifier for the IdP
2054-
# * idp_name: user-facing name for the IdP
2055-
# * idp_icon: if specified in the IdP config, an MXC URI for an icon
2056-
# for the IdP
2057-
# * idp_brand: if specified in the IdP config, a textual identifier
2058-
# for the brand of the IdP
2059-
#
2060-
# * HTML page shown after a successful user interactive authentication session:
2061-
# 'sso_auth_success.html'.
2062-
#
2063-
# Note that this page must include the JavaScript which notifies of a successful authentication
2064-
# (see https://matrix.org/docs/spec/client_server/r0.6.0#fallback).
2065-
#
2066-
# This template has no additional variables.
2067-
#
2068-
# * HTML page shown after a user-interactive authentication session which
2069-
# does not map correctly onto the expected user: 'sso_auth_bad_user.html'.
2070-
#
2071-
# When rendering, this template is given the following variables:
2072-
# * server_name: the homeserver's name.
2073-
# * user_id_to_verify: the MXID of the user that we are trying to
2074-
# validate.
2075-
#
2076-
# * HTML page shown during single sign-on if a deactivated user (according to Synapse's database)
2077-
# attempts to login: 'sso_account_deactivated.html'.
2078-
#
2079-
# This template has no additional variables.
2080-
#
2081-
# * HTML page to display to users if something goes wrong during the
2082-
# OpenID Connect authentication process: 'sso_error.html'.
2083-
#
2084-
# When rendering, this template is given two variables:
2085-
# * error: the technical name of the error
2086-
# * error_description: a human-readable message for the error
2087-
#
2088-
# You can see the default templates at:
2089-
# https://github.com/matrix-org/synapse/tree/master/synapse/res/templates
2090-
#
2091-
#template_dir: "res/templates"
2092-
20931946

20941947
# JSON web token integration. The following settings can be used to make
20951948
# Synapse JSON web tokens for authentication, instead of its internal
@@ -2220,6 +2073,9 @@ ui_auth:
22202073

22212074
# Configuration for sending emails from Synapse.
22222075
#
2076+
# Server admins can configure custom templates for email content. See
2077+
# https://matrix-org.github.io/synapse/latest/templates.html for more information.
2078+
#
22232079
email:
22242080
# The hostname of the outgoing SMTP server to use. Defaults to 'localhost'.
22252081
#
@@ -2296,49 +2152,6 @@ email:
22962152
#
22972153
#invite_client_location: https://app.element.io
22982154

2299-
# Directory in which Synapse will try to find the template files below.
2300-
# If not set, or the files named below are not found within the template
2301-
# directory, default templates from within the Synapse package will be used.
2302-
#
2303-
# Synapse will look for the following templates in this directory:
2304-
#
2305-
# * The contents of email notifications of missed events: 'notif_mail.html' and
2306-
# 'notif_mail.txt'.
2307-
#
2308-
# * The contents of account expiry notice emails: 'notice_expiry.html' and
2309-
# 'notice_expiry.txt'.
2310-
#
2311-
# * The contents of password reset emails sent by the homeserver:
2312-
# 'password_reset.html' and 'password_reset.txt'
2313-
#
2314-
# * An HTML page that a user will see when they follow the link in the password
2315-
# reset email. The user will be asked to confirm the action before their
2316-
# password is reset: 'password_reset_confirmation.html'
2317-
#
2318-
# * HTML pages for success and failure that a user will see when they confirm
2319-
# the password reset flow using the page above: 'password_reset_success.html'
2320-
# and 'password_reset_failure.html'
2321-
#
2322-
# * The contents of address verification emails sent during registration:
2323-
# 'registration.html' and 'registration.txt'
2324-
#
2325-
# * HTML pages for success and failure that a user will see when they follow
2326-
# the link in an address verification email sent during registration:
2327-
# 'registration_success.html' and 'registration_failure.html'
2328-
#
2329-
# * The contents of address verification emails sent when an address is added
2330-
# to a Matrix account: 'add_threepid.html' and 'add_threepid.txt'
2331-
#
2332-
# * HTML pages for success and failure that a user will see when they follow
2333-
# the link in an address verification email sent when an address is added
2334-
# to a Matrix account: 'add_threepid_success.html' and
2335-
# 'add_threepid_failure.html'
2336-
#
2337-
# You can see the default templates at:
2338-
# https://github.com/matrix-org/synapse/tree/master/synapse/res/templates
2339-
#
2340-
#template_dir: "res/templates"
2341-
23422155
# Subjects to use when sending emails from Synapse.
23432156
#
23442157
# The placeholder '%(app)s' will be replaced with the value of the 'app_name'

0 commit comments

Comments
 (0)