UPGRADE.rst 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. Upgrading Synapse
  2. =================
  3. Before upgrading check if any special steps are required to upgrade from the
  4. version you currently have installed to the current version of Synapse. The extra
  5. instructions that may be required are listed later in this document.
  6. * Check that your versions of Python and PostgreSQL are still supported.
  7. Synapse follows upstream lifecycles for `Python`_ and `PostgreSQL`_, and
  8. removes support for versions which are no longer maintained.
  9. The website https://endoflife.date also offers convenient summaries.
  10. .. _Python: https://devguide.python.org/devcycle/#end-of-life-branches
  11. .. _PostgreSQL: https://www.postgresql.org/support/versioning/
  12. * If Synapse was installed using `prebuilt packages
  13. <INSTALL.md#prebuilt-packages>`_, you will need to follow the normal process
  14. for upgrading those packages.
  15. * If Synapse was installed from source, then:
  16. 1. Activate the virtualenv before upgrading. For example, if Synapse is
  17. installed in a virtualenv in ``~/synapse/env`` then run:
  18. .. code:: bash
  19. source ~/synapse/env/bin/activate
  20. 2. If Synapse was installed using pip then upgrade to the latest version by
  21. running:
  22. .. code:: bash
  23. pip install --upgrade matrix-synapse
  24. If Synapse was installed using git then upgrade to the latest version by
  25. running:
  26. .. code:: bash
  27. git pull
  28. pip install --upgrade .
  29. 3. Restart Synapse:
  30. .. code:: bash
  31. ./synctl restart
  32. To check whether your update was successful, you can check the running server
  33. version with:
  34. .. code:: bash
  35. # you may need to replace 'localhost:8008' if synapse is not configured
  36. # to listen on port 8008.
  37. curl http://localhost:8008/_synapse/admin/v1/server_version
  38. Rolling back to older versions
  39. ------------------------------
  40. Rolling back to previous releases can be difficult, due to database schema
  41. changes between releases. Where we have been able to test the rollback process,
  42. this will be noted below.
  43. In general, you will need to undo any changes made during the upgrade process,
  44. for example:
  45. * pip:
  46. .. code:: bash
  47. source env/bin/activate
  48. # replace `1.3.0` accordingly:
  49. pip install matrix-synapse==1.3.0
  50. * Debian:
  51. .. code:: bash
  52. # replace `1.3.0` and `stretch` accordingly:
  53. wget https://packages.matrix.org/debian/pool/main/m/matrix-synapse-py3/matrix-synapse-py3_1.3.0+stretch1_amd64.deb
  54. dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
  55. Upgrading to v1.27.0
  56. ====================
  57. Changes to callback URI for OAuth2 / OpenID Connect
  58. ---------------------------------------------------
  59. This version changes the URI used for callbacks from OAuth2 identity providers. If
  60. your server is configured for single sign-on via an OpenID Connect or OAuth2 identity
  61. provider, you will need to add ``[synapse public baseurl]/_synapse/client/oidc/callback``
  62. to the list of permitted "redirect URIs" at the identity provider.
  63. See `docs/openid.md <docs/openid.md>`_ for more information on setting up OpenID
  64. Connect.
  65. (Note: a similar change is being made for SAML2; in this case the old URI
  66. ``[synapse public baseurl]/_matrix/saml2`` is being deprecated, but will continue to
  67. work, so no immediate changes are required for existing installations.)
  68. Changes to HTML templates
  69. -------------------------
  70. The HTML templates for SSO and email notifications now have `Jinja2's autoescape <https://jinja.palletsprojects.com/en/2.11.x/api/#autoescaping>`_
  71. enabled for files ending in ``.html``, ``.htm``, and ``.xml``. If you have customised
  72. these templates and see issues when viewing them you might need to update them.
  73. It is expected that most configurations will need no changes.
  74. If you have customised the templates *names* for these templates, it is recommended
  75. to verify they end in ``.html`` to ensure autoescape is enabled.
  76. The above applies to the following templates:
  77. * ``add_threepid.html``
  78. * ``add_threepid_failure.html``
  79. * ``add_threepid_success.html``
  80. * ``notice_expiry.html``
  81. * ``notice_expiry.html``
  82. * ``notif_mail.html`` (which, by default, includes ``room.html`` and ``notif.html``)
  83. * ``password_reset.html``
  84. * ``password_reset_confirmation.html``
  85. * ``password_reset_failure.html``
  86. * ``password_reset_success.html``
  87. * ``registration.html``
  88. * ``registration_failure.html``
  89. * ``registration_success.html``
  90. * ``sso_account_deactivated.html``
  91. * ``sso_auth_bad_user.html``
  92. * ``sso_auth_confirm.html``
  93. * ``sso_auth_success.html``
  94. * ``sso_error.html``
  95. * ``sso_login_idp_picker.html``
  96. * ``sso_redirect_confirm.html``
  97. Upgrading to v1.26.0
  98. ====================
  99. Rolling back to v1.25.0 after a failed upgrade
  100. ----------------------------------------------
  101. v1.26.0 includes a lot of large changes. If something problematic occurs, you
  102. may want to roll-back to a previous version of Synapse. Because v1.26.0 also
  103. includes a new database schema version, reverting that version is also required
  104. alongside the generic rollback instructions mentioned above. In short, to roll
  105. back to v1.25.0 you need to:
  106. 1. Stop the server
  107. 2. Decrease the schema version in the database:
  108. .. code:: sql
  109. UPDATE schema_version SET version = 58;
  110. 3. Delete the ignored users & chain cover data:
  111. .. code:: sql
  112. DROP TABLE IF EXISTS ignored_users;
  113. UPDATE rooms SET has_auth_chain_index = false;
  114. For PostgreSQL run:
  115. .. code:: sql
  116. TRUNCATE event_auth_chain_links;
  117. TRUNCATE event_auth_chains;
  118. For SQLite run:
  119. .. code:: sql
  120. DELETE FROM event_auth_chain_links;
  121. DELETE FROM event_auth_chains;
  122. 4. Mark the deltas as not run (so they will re-run on upgrade).
  123. .. code:: sql
  124. DELETE FROM applied_schema_deltas WHERE version = 59 AND file = "59/01ignored_user.py";
  125. DELETE FROM applied_schema_deltas WHERE version = 59 AND file = "59/06chain_cover_index.sql";
  126. 5. Downgrade Synapse by following the instructions for your installation method
  127. in the "Rolling back to older versions" section above.
  128. Upgrading to v1.25.0
  129. ====================
  130. Last release supporting Python 3.5
  131. ----------------------------------
  132. This is the last release of Synapse which guarantees support with Python 3.5,
  133. which passed its upstream End of Life date several months ago.
  134. We will attempt to maintain support through March 2021, but without guarantees.
  135. In the future, Synapse will follow upstream schedules for ending support of
  136. older versions of Python and PostgreSQL. Please upgrade to at least Python 3.6
  137. and PostgreSQL 9.6 as soon as possible.
  138. Blacklisting IP ranges
  139. ----------------------
  140. Synapse v1.25.0 includes new settings, ``ip_range_blacklist`` and
  141. ``ip_range_whitelist``, for controlling outgoing requests from Synapse for federation,
  142. identity servers, push, and for checking key validity for third-party invite events.
  143. The previous setting, ``federation_ip_range_blacklist``, is deprecated. The new
  144. ``ip_range_blacklist`` defaults to private IP ranges if it is not defined.
  145. If you have never customised ``federation_ip_range_blacklist`` it is recommended
  146. that you remove that setting.
  147. If you have customised ``federation_ip_range_blacklist`` you should update the
  148. setting name to ``ip_range_blacklist``.
  149. If you have a custom push server that is reached via private IP space you may
  150. need to customise ``ip_range_blacklist`` or ``ip_range_whitelist``.
  151. Upgrading to v1.24.0
  152. ====================
  153. Custom OpenID Connect mapping provider breaking change
  154. ------------------------------------------------------
  155. This release allows the OpenID Connect mapping provider to perform normalisation
  156. of the localpart of the Matrix ID. This allows for the mapping provider to
  157. specify different algorithms, instead of the [default way](https://matrix.org/docs/spec/appendices#mapping-from-other-character-sets).
  158. If your Synapse configuration uses a custom mapping provider
  159. (`oidc_config.user_mapping_provider.module` is specified and not equal to
  160. `synapse.handlers.oidc_handler.JinjaOidcMappingProvider`) then you *must* ensure
  161. that `map_user_attributes` of the mapping provider performs some normalisation
  162. of the `localpart` returned. To match previous behaviour you can use the
  163. `map_username_to_mxid_localpart` function provided by Synapse. An example is
  164. shown below:
  165. .. code-block:: python
  166. from synapse.types import map_username_to_mxid_localpart
  167. class MyMappingProvider:
  168. def map_user_attributes(self, userinfo, token):
  169. # ... your custom logic ...
  170. sso_user_id = ...
  171. localpart = map_username_to_mxid_localpart(sso_user_id)
  172. return {"localpart": localpart}
  173. Removal historical Synapse Admin API
  174. ------------------------------------
  175. Historically, the Synapse Admin API has been accessible under:
  176. * ``/_matrix/client/api/v1/admin``
  177. * ``/_matrix/client/unstable/admin``
  178. * ``/_matrix/client/r0/admin``
  179. * ``/_synapse/admin/v1``
  180. The endpoints with ``/_matrix/client/*`` prefixes have been removed as of v1.24.0.
  181. The Admin API is now only accessible under:
  182. * ``/_synapse/admin/v1``
  183. The only exception is the `/admin/whois` endpoint, which is
  184. `also available via the client-server API <https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-admin-whois-userid>`_.
  185. The deprecation of the old endpoints was announced with Synapse 1.20.0 (released
  186. on 2020-09-22) and makes it easier for homeserver admins to lock down external
  187. access to the Admin API endpoints.
  188. Upgrading to v1.23.0
  189. ====================
  190. Structured logging configuration breaking changes
  191. -------------------------------------------------
  192. This release deprecates use of the ``structured: true`` logging configuration for
  193. structured logging. If your logging configuration contains ``structured: true``
  194. then it should be modified based on the `structured logging documentation
  195. <https://github.com/matrix-org/synapse/blob/master/docs/structured_logging.md>`_.
  196. The ``structured`` and ``drains`` logging options are now deprecated and should
  197. be replaced by standard logging configuration of ``handlers`` and ``formatters``.
  198. A future will release of Synapse will make using ``structured: true`` an error.
  199. Upgrading to v1.22.0
  200. ====================
  201. ThirdPartyEventRules breaking changes
  202. -------------------------------------
  203. This release introduces a backwards-incompatible change to modules making use of
  204. ``ThirdPartyEventRules`` in Synapse. If you make use of a module defined under the
  205. ``third_party_event_rules`` config option, please make sure it is updated to handle
  206. the below change:
  207. The ``http_client`` argument is no longer passed to modules as they are initialised. Instead,
  208. modules are expected to make use of the ``http_client`` property on the ``ModuleApi`` class.
  209. Modules are now passed a ``module_api`` argument during initialisation, which is an instance of
  210. ``ModuleApi``. ``ModuleApi`` instances have a ``http_client`` property which acts the same as
  211. the ``http_client`` argument previously passed to ``ThirdPartyEventRules`` modules.
  212. Upgrading to v1.21.0
  213. ====================
  214. Forwarding ``/_synapse/client`` through your reverse proxy
  215. ----------------------------------------------------------
  216. The `reverse proxy documentation
  217. <https://github.com/matrix-org/synapse/blob/develop/docs/reverse_proxy.md>`_ has been updated
  218. to include reverse proxy directives for ``/_synapse/client/*`` endpoints. As the user password
  219. reset flow now uses endpoints under this prefix, **you must update your reverse proxy
  220. configurations for user password reset to work**.
  221. Additionally, note that the `Synapse worker documentation
  222. <https://github.com/matrix-org/synapse/blob/develop/docs/workers.md>`_ has been updated to
  223. state that the ``/_synapse/client/password_reset/email/submit_token`` endpoint can be handled
  224. by all workers. If you make use of Synapse's worker feature, please update your reverse proxy
  225. configuration to reflect this change.
  226. New HTML templates
  227. ------------------
  228. A new HTML template,
  229. `password_reset_confirmation.html <https://github.com/matrix-org/synapse/blob/develop/synapse/res/templates/password_reset_confirmation.html>`_,
  230. has been added to the ``synapse/res/templates`` directory. If you are using a
  231. custom template directory, you may want to copy the template over and modify it.
  232. Note that as of v1.20.0, templates do not need to be included in custom template
  233. directories for Synapse to start. The default templates will be used if a custom
  234. template cannot be found.
  235. This page will appear to the user after clicking a password reset link that has
  236. been emailed to them.
  237. To complete password reset, the page must include a way to make a `POST`
  238. request to
  239. ``/_synapse/client/password_reset/{medium}/submit_token``
  240. with the query parameters from the original link, presented as a URL-encoded form. See the file
  241. itself for more details.
  242. Updated Single Sign-on HTML Templates
  243. -------------------------------------
  244. The ``saml_error.html`` template was removed from Synapse and replaced with the
  245. ``sso_error.html`` template. If your Synapse is configured to use SAML and a
  246. custom ``sso_redirect_confirm_template_dir`` configuration then any customisations
  247. of the ``saml_error.html`` template will need to be merged into the ``sso_error.html``
  248. template. These templates are similar, but the parameters are slightly different:
  249. * The ``msg`` parameter should be renamed to ``error_description``.
  250. * There is no longer a ``code`` parameter for the response code.
  251. * A string ``error`` parameter is available that includes a short hint of why a
  252. user is seeing the error page.
  253. Upgrading to v1.18.0
  254. ====================
  255. Docker `-py3` suffix will be removed in future versions
  256. -------------------------------------------------------
  257. From 10th August 2020, we will no longer publish Docker images with the `-py3` tag suffix. The images tagged with the `-py3` suffix have been identical to the non-suffixed tags since release 0.99.0, and the suffix is obsolete.
  258. On 10th August, we will remove the `latest-py3` tag. Existing per-release tags (such as `v1.18.0-py3`) will not be removed, but no new `-py3` tags will be added.
  259. Scripts relying on the `-py3` suffix will need to be updated.
  260. Redis replication is now recommended in lieu of TCP replication
  261. ---------------------------------------------------------------
  262. When setting up worker processes, we now recommend the use of a Redis server for replication. **The old direct TCP connection method is deprecated and will be removed in a future release.**
  263. See `docs/workers.md <docs/workers.md>`_ for more details.
  264. Upgrading to v1.14.0
  265. ====================
  266. This version includes a database update which is run as part of the upgrade,
  267. and which may take a couple of minutes in the case of a large server. Synapse
  268. will not respond to HTTP requests while this update is taking place.
  269. Upgrading to v1.13.0
  270. ====================
  271. Incorrect database migration in old synapse versions
  272. ----------------------------------------------------
  273. A bug was introduced in Synapse 1.4.0 which could cause the room directory to
  274. be incomplete or empty if Synapse was upgraded directly from v1.2.1 or
  275. earlier, to versions between v1.4.0 and v1.12.x.
  276. This will *not* be a problem for Synapse installations which were:
  277. * created at v1.4.0 or later,
  278. * upgraded via v1.3.x, or
  279. * upgraded straight from v1.2.1 or earlier to v1.13.0 or later.
  280. If completeness of the room directory is a concern, installations which are
  281. affected can be repaired as follows:
  282. 1. Run the following sql from a `psql` or `sqlite3` console:
  283. .. code:: sql
  284. INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
  285. ('populate_stats_process_rooms', '{}', 'current_state_events_membership');
  286. INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
  287. ('populate_stats_process_users', '{}', 'populate_stats_process_rooms');
  288. 2. Restart synapse.
  289. New Single Sign-on HTML Templates
  290. ---------------------------------
  291. New templates (``sso_auth_confirm.html``, ``sso_auth_success.html``, and
  292. ``sso_account_deactivated.html``) were added to Synapse. If your Synapse is
  293. configured to use SSO and a custom ``sso_redirect_confirm_template_dir``
  294. configuration then these templates will need to be copied from
  295. `synapse/res/templates <synapse/res/templates>`_ into that directory.
  296. Synapse SSO Plugins Method Deprecation
  297. --------------------------------------
  298. Plugins using the ``complete_sso_login`` method of
  299. ``synapse.module_api.ModuleApi`` should update to using the async/await
  300. version ``complete_sso_login_async`` which includes additional checks. The
  301. non-async version is considered deprecated.
  302. Rolling back to v1.12.4 after a failed upgrade
  303. ----------------------------------------------
  304. v1.13.0 includes a lot of large changes. If something problematic occurs, you
  305. may want to roll-back to a previous version of Synapse. Because v1.13.0 also
  306. includes a new database schema version, reverting that version is also required
  307. alongside the generic rollback instructions mentioned above. In short, to roll
  308. back to v1.12.4 you need to:
  309. 1. Stop the server
  310. 2. Decrease the schema version in the database:
  311. .. code:: sql
  312. UPDATE schema_version SET version = 57;
  313. 3. Downgrade Synapse by following the instructions for your installation method
  314. in the "Rolling back to older versions" section above.
  315. Upgrading to v1.12.0
  316. ====================
  317. This version includes a database update which is run as part of the upgrade,
  318. and which may take some time (several hours in the case of a large
  319. server). Synapse will not respond to HTTP requests while this update is taking
  320. place.
  321. This is only likely to be a problem in the case of a server which is
  322. participating in many rooms.
  323. 0. As with all upgrades, it is recommended that you have a recent backup of
  324. your database which can be used for recovery in the event of any problems.
  325. 1. As an initial check to see if you will be affected, you can try running the
  326. following query from the `psql` or `sqlite3` console. It is safe to run it
  327. while Synapse is still running.
  328. .. code:: sql
  329. SELECT MAX(q.v) FROM (
  330. SELECT (
  331. SELECT ej.json AS v
  332. FROM state_events se INNER JOIN event_json ej USING (event_id)
  333. WHERE se.room_id=rooms.room_id AND se.type='m.room.create' AND se.state_key=''
  334. LIMIT 1
  335. ) FROM rooms WHERE rooms.room_version IS NULL
  336. ) q;
  337. This query will take about the same amount of time as the upgrade process: ie,
  338. if it takes 5 minutes, then it is likely that Synapse will be unresponsive for
  339. 5 minutes during the upgrade.
  340. If you consider an outage of this duration to be acceptable, no further
  341. action is necessary and you can simply start Synapse 1.12.0.
  342. If you would prefer to reduce the downtime, continue with the steps below.
  343. 2. The easiest workaround for this issue is to manually
  344. create a new index before upgrading. On PostgreSQL, his can be done as follows:
  345. .. code:: sql
  346. CREATE INDEX CONCURRENTLY tmp_upgrade_1_12_0_index
  347. ON state_events(room_id) WHERE type = 'm.room.create';
  348. The above query may take some time, but is also safe to run while Synapse is
  349. running.
  350. We assume that no SQLite users have databases large enough to be
  351. affected. If you *are* affected, you can run a similar query, omitting the
  352. ``CONCURRENTLY`` keyword. Note however that this operation may in itself cause
  353. Synapse to stop running for some time. Synapse admins are reminded that
  354. `SQLite is not recommended for use outside a test
  355. environment <https://github.com/matrix-org/synapse/blob/master/README.rst#using-postgresql>`_.
  356. 3. Once the index has been created, the ``SELECT`` query in step 1 above should
  357. complete quickly. It is therefore safe to upgrade to Synapse 1.12.0.
  358. 4. Once Synapse 1.12.0 has successfully started and is responding to HTTP
  359. requests, the temporary index can be removed:
  360. .. code:: sql
  361. DROP INDEX tmp_upgrade_1_12_0_index;
  362. Upgrading to v1.10.0
  363. ====================
  364. Synapse will now log a warning on start up if used with a PostgreSQL database
  365. that has a non-recommended locale set.
  366. See `docs/postgres.md <docs/postgres.md>`_ for details.
  367. Upgrading to v1.8.0
  368. ===================
  369. Specifying a ``log_file`` config option will now cause Synapse to refuse to
  370. start, and should be replaced by with the ``log_config`` option. Support for
  371. the ``log_file`` option was removed in v1.3.0 and has since had no effect.
  372. Upgrading to v1.7.0
  373. ===================
  374. In an attempt to configure Synapse in a privacy preserving way, the default
  375. behaviours of ``allow_public_rooms_without_auth`` and
  376. ``allow_public_rooms_over_federation`` have been inverted. This means that by
  377. default, only authenticated users querying the Client/Server API will be able
  378. to query the room directory, and relatedly that the server will not share
  379. room directory information with other servers over federation.
  380. If your installation does not explicitly set these settings one way or the other
  381. and you want either setting to be ``true`` then it will necessary to update
  382. your homeserver configuration file accordingly.
  383. For more details on the surrounding context see our `explainer
  384. <https://matrix.org/blog/2019/11/09/avoiding-unwelcome-visitors-on-private-matrix-servers>`_.
  385. Upgrading to v1.5.0
  386. ===================
  387. This release includes a database migration which may take several minutes to
  388. complete if there are a large number (more than a million or so) of entries in
  389. the ``devices`` table. This is only likely to a be a problem on very large
  390. installations.
  391. Upgrading to v1.4.0
  392. ===================
  393. New custom templates
  394. --------------------
  395. If you have configured a custom template directory with the
  396. ``email.template_dir`` option, be aware that there are new templates regarding
  397. registration and threepid management (see below) that must be included.
  398. * ``registration.html`` and ``registration.txt``
  399. * ``registration_success.html`` and ``registration_failure.html``
  400. * ``add_threepid.html`` and ``add_threepid.txt``
  401. * ``add_threepid_failure.html`` and ``add_threepid_success.html``
  402. Synapse will expect these files to exist inside the configured template
  403. directory, and **will fail to start** if they are absent.
  404. To view the default templates, see `synapse/res/templates
  405. <https://github.com/matrix-org/synapse/tree/master/synapse/res/templates>`_.
  406. 3pid verification changes
  407. -------------------------
  408. **Note: As of this release, users will be unable to add phone numbers or email
  409. addresses to their accounts, without changes to the Synapse configuration. This
  410. includes adding an email address during registration.**
  411. It is possible for a user to associate an email address or phone number
  412. with their account, for a number of reasons:
  413. * for use when logging in, as an alternative to the user id.
  414. * in the case of email, as an alternative contact to help with account recovery.
  415. * in the case of email, to receive notifications of missed messages.
  416. Before an email address or phone number can be added to a user's account,
  417. or before such an address is used to carry out a password-reset, Synapse must
  418. confirm the operation with the owner of the email address or phone number.
  419. It does this by sending an email or text giving the user a link or token to confirm
  420. receipt. This process is known as '3pid verification'. ('3pid', or 'threepid',
  421. stands for third-party identifier, and we use it to refer to external
  422. identifiers such as email addresses and phone numbers.)
  423. Previous versions of Synapse delegated the task of 3pid verification to an
  424. identity server by default. In most cases this server is ``vector.im`` or
  425. ``matrix.org``.
  426. In Synapse 1.4.0, for security and privacy reasons, the homeserver will no
  427. longer delegate this task to an identity server by default. Instead,
  428. the server administrator will need to explicitly decide how they would like the
  429. verification messages to be sent.
  430. In the medium term, the ``vector.im`` and ``matrix.org`` identity servers will
  431. disable support for delegated 3pid verification entirely. However, in order to
  432. ease the transition, they will retain the capability for a limited
  433. period. Delegated email verification will be disabled on Monday 2nd December
  434. 2019 (giving roughly 2 months notice). Disabling delegated SMS verification
  435. will follow some time after that once SMS verification support lands in
  436. Synapse.
  437. Once delegated 3pid verification support has been disabled in the ``vector.im`` and
  438. ``matrix.org`` identity servers, all Synapse versions that depend on those
  439. instances will be unable to verify email and phone numbers through them. There
  440. are no imminent plans to remove delegated 3pid verification from Sydent
  441. generally. (Sydent is the identity server project that backs the ``vector.im`` and
  442. ``matrix.org`` instances).
  443. Email
  444. ~~~~~
  445. Following upgrade, to continue verifying email (e.g. as part of the
  446. registration process), admins can either:-
  447. * Configure Synapse to use an email server.
  448. * Run or choose an identity server which allows delegated email verification
  449. and delegate to it.
  450. Configure SMTP in Synapse
  451. +++++++++++++++++++++++++
  452. To configure an SMTP server for Synapse, modify the configuration section
  453. headed ``email``, and be sure to have at least the ``smtp_host, smtp_port``
  454. and ``notif_from`` fields filled out.
  455. You may also need to set ``smtp_user``, ``smtp_pass``, and
  456. ``require_transport_security``.
  457. See the `sample configuration file <docs/sample_config.yaml>`_ for more details
  458. on these settings.
  459. Delegate email to an identity server
  460. ++++++++++++++++++++++++++++++++++++
  461. Some admins will wish to continue using email verification as part of the
  462. registration process, but will not immediately have an appropriate SMTP server
  463. at hand.
  464. To this end, we will continue to support email verification delegation via the
  465. ``vector.im`` and ``matrix.org`` identity servers for two months. Support for
  466. delegated email verification will be disabled on Monday 2nd December.
  467. The ``account_threepid_delegates`` dictionary defines whether the homeserver
  468. should delegate an external server (typically an `identity server
  469. <https://matrix.org/docs/spec/identity_service/r0.2.1>`_) to handle sending
  470. confirmation messages via email and SMS.
  471. So to delegate email verification, in ``homeserver.yaml``, set
  472. ``account_threepid_delegates.email`` to the base URL of an identity server. For
  473. example:
  474. .. code:: yaml
  475. account_threepid_delegates:
  476. email: https://example.com # Delegate email sending to example.com
  477. Note that ``account_threepid_delegates.email`` replaces the deprecated
  478. ``email.trust_identity_server_for_password_resets``: if
  479. ``email.trust_identity_server_for_password_resets`` is set to ``true``, and
  480. ``account_threepid_delegates.email`` is not set, then the first entry in
  481. ``trusted_third_party_id_servers`` will be used as the
  482. ``account_threepid_delegate`` for email. This is to ensure compatibility with
  483. existing Synapse installs that set up external server handling for these tasks
  484. before v1.4.0. If ``email.trust_identity_server_for_password_resets`` is
  485. ``true`` and no trusted identity server domains are configured, Synapse will
  486. report an error and refuse to start.
  487. If ``email.trust_identity_server_for_password_resets`` is ``false`` or absent
  488. and no ``email`` delegate is configured in ``account_threepid_delegates``,
  489. then Synapse will send email verification messages itself, using the configured
  490. SMTP server (see above).
  491. that type.
  492. Phone numbers
  493. ~~~~~~~~~~~~~
  494. Synapse does not support phone-number verification itself, so the only way to
  495. maintain the ability for users to add phone numbers to their accounts will be
  496. by continuing to delegate phone number verification to the ``matrix.org`` and
  497. ``vector.im`` identity servers (or another identity server that supports SMS
  498. sending).
  499. The ``account_threepid_delegates`` dictionary defines whether the homeserver
  500. should delegate an external server (typically an `identity server
  501. <https://matrix.org/docs/spec/identity_service/r0.2.1>`_) to handle sending
  502. confirmation messages via email and SMS.
  503. So to delegate phone number verification, in ``homeserver.yaml``, set
  504. ``account_threepid_delegates.msisdn`` to the base URL of an identity
  505. server. For example:
  506. .. code:: yaml
  507. account_threepid_delegates:
  508. msisdn: https://example.com # Delegate sms sending to example.com
  509. The ``matrix.org`` and ``vector.im`` identity servers will continue to support
  510. delegated phone number verification via SMS until such time as it is possible
  511. for admins to configure their servers to perform phone number verification
  512. directly. More details will follow in a future release.
  513. Rolling back to v1.3.1
  514. ----------------------
  515. If you encounter problems with v1.4.0, it should be possible to roll back to
  516. v1.3.1, subject to the following:
  517. * The 'room statistics' engine was heavily reworked in this release (see
  518. `#5971 <https://github.com/matrix-org/synapse/pull/5971>`_), including
  519. significant changes to the database schema, which are not easily
  520. reverted. This will cause the room statistics engine to stop updating when
  521. you downgrade.
  522. The room statistics are essentially unused in v1.3.1 (in future versions of
  523. Synapse, they will be used to populate the room directory), so there should
  524. be no loss of functionality. However, the statistics engine will write errors
  525. to the logs, which can be avoided by setting the following in
  526. `homeserver.yaml`:
  527. .. code:: yaml
  528. stats:
  529. enabled: false
  530. Don't forget to re-enable it when you upgrade again, in preparation for its
  531. use in the room directory!
  532. Upgrading to v1.2.0
  533. ===================
  534. Some counter metrics have been renamed, with the old names deprecated. See
  535. `the metrics documentation <docs/metrics-howto.md#renaming-of-metrics--deprecation-of-old-names-in-12>`_
  536. for details.
  537. Upgrading to v1.1.0
  538. ===================
  539. Synapse v1.1.0 removes support for older Python and PostgreSQL versions, as
  540. outlined in `our deprecation notice <https://matrix.org/blog/2019/04/08/synapse-deprecating-postgres-9-4-and-python-2-x>`_.
  541. Minimum Python Version
  542. ----------------------
  543. Synapse v1.1.0 has a minimum Python requirement of Python 3.5. Python 3.6 or
  544. Python 3.7 are recommended as they have improved internal string handling,
  545. significantly reducing memory usage.
  546. If you use current versions of the Matrix.org-distributed Debian packages or
  547. Docker images, action is not required.
  548. If you install Synapse in a Python virtual environment, please see "Upgrading to
  549. v0.34.0" for notes on setting up a new virtualenv under Python 3.
  550. Minimum PostgreSQL Version
  551. --------------------------
  552. If using PostgreSQL under Synapse, you will need to use PostgreSQL 9.5 or above.
  553. Please see the
  554. `PostgreSQL documentation <https://www.postgresql.org/docs/11/upgrading.html>`_
  555. for more details on upgrading your database.
  556. Upgrading to v1.0
  557. =================
  558. Validation of TLS certificates
  559. ------------------------------
  560. Synapse v1.0 is the first release to enforce
  561. validation of TLS certificates for the federation API. It is therefore
  562. essential that your certificates are correctly configured. See the `FAQ
  563. <docs/MSC1711_certificates_FAQ.md>`_ for more information.
  564. Note, v1.0 installations will also no longer be able to federate with servers
  565. that have not correctly configured their certificates.
  566. In rare cases, it may be desirable to disable certificate checking: for
  567. example, it might be essential to be able to federate with a given legacy
  568. server in a closed federation. This can be done in one of two ways:-
  569. * Configure the global switch ``federation_verify_certificates`` to ``false``.
  570. * Configure a whitelist of server domains to trust via ``federation_certificate_verification_whitelist``.
  571. See the `sample configuration file <docs/sample_config.yaml>`_
  572. for more details on these settings.
  573. Email
  574. -----
  575. When a user requests a password reset, Synapse will send an email to the
  576. user to confirm the request.
  577. Previous versions of Synapse delegated the job of sending this email to an
  578. identity server. If the identity server was somehow malicious or became
  579. compromised, it would be theoretically possible to hijack an account through
  580. this means.
  581. Therefore, by default, Synapse v1.0 will send the confirmation email itself. If
  582. Synapse is not configured with an SMTP server, password reset via email will be
  583. disabled.
  584. To configure an SMTP server for Synapse, modify the configuration section
  585. headed ``email``, and be sure to have at least the ``smtp_host``, ``smtp_port``
  586. and ``notif_from`` fields filled out. You may also need to set ``smtp_user``,
  587. ``smtp_pass``, and ``require_transport_security``.
  588. If you are absolutely certain that you wish to continue using an identity
  589. server for password resets, set ``trust_identity_server_for_password_resets`` to ``true``.
  590. See the `sample configuration file <docs/sample_config.yaml>`_
  591. for more details on these settings.
  592. New email templates
  593. ---------------
  594. Some new templates have been added to the default template directory for the purpose of the
  595. homeserver sending its own password reset emails. If you have configured a custom
  596. ``template_dir`` in your Synapse config, these files will need to be added.
  597. ``password_reset.html`` and ``password_reset.txt`` are HTML and plain text templates
  598. respectively that contain the contents of what will be emailed to the user upon attempting to
  599. reset their password via email. ``password_reset_success.html`` and
  600. ``password_reset_failure.html`` are HTML files that the content of which (assuming no redirect
  601. URL is set) will be shown to the user after they attempt to click the link in the email sent
  602. to them.
  603. Upgrading to v0.99.0
  604. ====================
  605. Please be aware that, before Synapse v1.0 is released around March 2019, you
  606. will need to replace any self-signed certificates with those verified by a
  607. root CA. Information on how to do so can be found at `the ACME docs
  608. <docs/ACME.md>`_.
  609. For more information on configuring TLS certificates see the `FAQ <docs/MSC1711_certificates_FAQ.md>`_.
  610. Upgrading to v0.34.0
  611. ====================
  612. 1. This release is the first to fully support Python 3. Synapse will now run on
  613. Python versions 3.5, or 3.6 (as well as 2.7). We recommend switching to
  614. Python 3, as it has been shown to give performance improvements.
  615. For users who have installed Synapse into a virtualenv, we recommend doing
  616. this by creating a new virtualenv. For example::
  617. virtualenv -p python3 ~/synapse/env3
  618. source ~/synapse/env3/bin/activate
  619. pip install matrix-synapse
  620. You can then start synapse as normal, having activated the new virtualenv::
  621. cd ~/synapse
  622. source env3/bin/activate
  623. synctl start
  624. Users who have installed from distribution packages should see the relevant
  625. package documentation. See below for notes on Debian packages.
  626. * When upgrading to Python 3, you **must** make sure that your log files are
  627. configured as UTF-8, by adding ``encoding: utf8`` to the
  628. ``RotatingFileHandler`` configuration (if you have one) in your
  629. ``<server>.log.config`` file. For example, if your ``log.config`` file
  630. contains::
  631. handlers:
  632. file:
  633. class: logging.handlers.RotatingFileHandler
  634. formatter: precise
  635. filename: homeserver.log
  636. maxBytes: 104857600
  637. backupCount: 10
  638. filters: [context]
  639. console:
  640. class: logging.StreamHandler
  641. formatter: precise
  642. filters: [context]
  643. Then you should update this to be::
  644. handlers:
  645. file:
  646. class: logging.handlers.RotatingFileHandler
  647. formatter: precise
  648. filename: homeserver.log
  649. maxBytes: 104857600
  650. backupCount: 10
  651. filters: [context]
  652. encoding: utf8
  653. console:
  654. class: logging.StreamHandler
  655. formatter: precise
  656. filters: [context]
  657. There is no need to revert this change if downgrading to Python 2.
  658. We are also making available Debian packages which will run Synapse on
  659. Python 3. You can switch to these packages with ``apt-get install
  660. matrix-synapse-py3``, however, please read `debian/NEWS
  661. <https://github.com/matrix-org/synapse/blob/release-v0.34.0/debian/NEWS>`_
  662. before doing so. The existing ``matrix-synapse`` packages will continue to
  663. use Python 2 for the time being.
  664. 2. This release removes the ``riot.im`` from the default list of trusted
  665. identity servers.
  666. If ``riot.im`` is in your homeserver's list of
  667. ``trusted_third_party_id_servers``, you should remove it. It was added in
  668. case a hypothetical future identity server was put there. If you don't
  669. remove it, users may be unable to deactivate their accounts.
  670. 3. This release no longer installs the (unmaintained) Matrix Console web client
  671. as part of the default installation. It is possible to re-enable it by
  672. installing it separately and setting the ``web_client_location`` config
  673. option, but please consider switching to another client.
  674. Upgrading to v0.33.7
  675. ====================
  676. This release removes the example email notification templates from
  677. ``res/templates`` (they are now internal to the python package). This should
  678. only affect you if you (a) deploy your Synapse instance from a git checkout or
  679. a github snapshot URL, and (b) have email notifications enabled.
  680. If you have email notifications enabled, you should ensure that
  681. ``email.template_dir`` is either configured to point at a directory where you
  682. have installed customised templates, or leave it unset to use the default
  683. templates.
  684. Upgrading to v0.27.3
  685. ====================
  686. This release expands the anonymous usage stats sent if the opt-in
  687. ``report_stats`` configuration is set to ``true``. We now capture RSS memory
  688. and cpu use at a very coarse level. This requires administrators to install
  689. the optional ``psutil`` python module.
  690. We would appreciate it if you could assist by ensuring this module is available
  691. and ``report_stats`` is enabled. This will let us see if performance changes to
  692. synapse are having an impact to the general community.
  693. Upgrading to v0.15.0
  694. ====================
  695. If you want to use the new URL previewing API (/_matrix/media/r0/preview_url)
  696. then you have to explicitly enable it in the config and update your dependencies
  697. dependencies. See README.rst for details.
  698. Upgrading to v0.11.0
  699. ====================
  700. This release includes the option to send anonymous usage stats to matrix.org,
  701. and requires that administrators explictly opt in or out by setting the
  702. ``report_stats`` option to either ``true`` or ``false``.
  703. We would really appreciate it if you could help our project out by reporting
  704. anonymized usage statistics from your homeserver. Only very basic aggregate
  705. data (e.g. number of users) will be reported, but it helps us to track the
  706. growth of the Matrix community, and helps us to make Matrix a success, as well
  707. as to convince other networks that they should peer with us.
  708. Upgrading to v0.9.0
  709. ===================
  710. Application services have had a breaking API change in this version.
  711. They can no longer register themselves with a home server using the AS HTTP API. This
  712. decision was made because a compromised application service with free reign to register
  713. any regex in effect grants full read/write access to the home server if a regex of ``.*``
  714. is used. An attack where a compromised AS re-registers itself with ``.*`` was deemed too
  715. big of a security risk to ignore, and so the ability to register with the HS remotely has
  716. been removed.
  717. It has been replaced by specifying a list of application service registrations in
  718. ``homeserver.yaml``::
  719. app_service_config_files: ["registration-01.yaml", "registration-02.yaml"]
  720. Where ``registration-01.yaml`` looks like::
  721. url: <String> # e.g. "https://my.application.service.com"
  722. as_token: <String>
  723. hs_token: <String>
  724. sender_localpart: <String> # This is a new field which denotes the user_id localpart when using the AS token
  725. namespaces:
  726. users:
  727. - exclusive: <Boolean>
  728. regex: <String> # e.g. "@prefix_.*"
  729. aliases:
  730. - exclusive: <Boolean>
  731. regex: <String>
  732. rooms:
  733. - exclusive: <Boolean>
  734. regex: <String>
  735. Upgrading to v0.8.0
  736. ===================
  737. Servers which use captchas will need to add their public key to::
  738. static/client/register/register_config.js
  739. window.matrixRegistrationConfig = {
  740. recaptcha_public_key: "YOUR_PUBLIC_KEY"
  741. };
  742. This is required in order to support registration fallback (typically used on
  743. mobile devices).
  744. Upgrading to v0.7.0
  745. ===================
  746. New dependencies are:
  747. - pydenticon
  748. - simplejson
  749. - syutil
  750. - matrix-angular-sdk
  751. To pull in these dependencies in a virtual env, run::
  752. python synapse/python_dependencies.py | xargs -n 1 pip install
  753. Upgrading to v0.6.0
  754. ===================
  755. To pull in new dependencies, run::
  756. python setup.py develop --user
  757. This update includes a change to the database schema. To upgrade you first need
  758. to upgrade the database by running::
  759. python scripts/upgrade_db_to_v0.6.0.py <db> <server_name> <signing_key>
  760. Where `<db>` is the location of the database, `<server_name>` is the
  761. server name as specified in the synapse configuration, and `<signing_key>` is
  762. the location of the signing key as specified in the synapse configuration.
  763. This may take some time to complete. Failures of signatures and content hashes
  764. can safely be ignored.
  765. Upgrading to v0.5.1
  766. ===================
  767. Depending on precisely when you installed v0.5.0 you may have ended up with
  768. a stale release of the reference matrix webclient installed as a python module.
  769. To uninstall it and ensure you are depending on the latest module, please run::
  770. $ pip uninstall syweb
  771. Upgrading to v0.5.0
  772. ===================
  773. The webclient has been split out into a seperate repository/pacakage in this
  774. release. Before you restart your homeserver you will need to pull in the
  775. webclient package by running::
  776. python setup.py develop --user
  777. This release completely changes the database schema and so requires upgrading
  778. it before starting the new version of the homeserver.
  779. The script "database-prepare-for-0.5.0.sh" should be used to upgrade the
  780. database. This will save all user information, such as logins and profiles,
  781. but will otherwise purge the database. This includes messages, which
  782. rooms the home server was a member of and room alias mappings.
  783. If you would like to keep your history, please take a copy of your database
  784. file and ask for help in #matrix:matrix.org. The upgrade process is,
  785. unfortunately, non trivial and requires human intervention to resolve any
  786. resulting conflicts during the upgrade process.
  787. Before running the command the homeserver should be first completely
  788. shutdown. To run it, simply specify the location of the database, e.g.:
  789. ./scripts/database-prepare-for-0.5.0.sh "homeserver.db"
  790. Once this has successfully completed it will be safe to restart the
  791. homeserver. You may notice that the homeserver takes a few seconds longer to
  792. restart than usual as it reinitializes the database.
  793. On startup of the new version, users can either rejoin remote rooms using room
  794. aliases or by being reinvited. Alternatively, if any other homeserver sends a
  795. message to a room that the homeserver was previously in the local HS will
  796. automatically rejoin the room.
  797. Upgrading to v0.4.0
  798. ===================
  799. This release needs an updated syutil version. Run::
  800. python setup.py develop
  801. You will also need to upgrade your configuration as the signing key format has
  802. changed. Run::
  803. python -m synapse.app.homeserver --config-path <CONFIG> --generate-config
  804. Upgrading to v0.3.0
  805. ===================
  806. This registration API now closely matches the login API. This introduces a bit
  807. more backwards and forwards between the HS and the client, but this improves
  808. the overall flexibility of the API. You can now GET on /register to retrieve a list
  809. of valid registration flows. Upon choosing one, they are submitted in the same
  810. way as login, e.g::
  811. {
  812. type: m.login.password,
  813. user: foo,
  814. password: bar
  815. }
  816. The default HS supports 2 flows, with and without Identity Server email
  817. authentication. Enabling captcha on the HS will add in an extra step to all
  818. flows: ``m.login.recaptcha`` which must be completed before you can transition
  819. to the next stage. There is a new login type: ``m.login.email.identity`` which
  820. contains the ``threepidCreds`` key which were previously sent in the original
  821. register request. For more information on this, see the specification.
  822. Web Client
  823. ----------
  824. The VoIP specification has changed between v0.2.0 and v0.3.0. Users should
  825. refresh any browser tabs to get the latest web client code. Users on
  826. v0.2.0 of the web client will not be able to call those on v0.3.0 and
  827. vice versa.
  828. Upgrading to v0.2.0
  829. ===================
  830. The home server now requires setting up of SSL config before it can run. To
  831. automatically generate default config use::
  832. $ python synapse/app/homeserver.py \
  833. --server-name machine.my.domain.name \
  834. --bind-port 8448 \
  835. --config-path homeserver.config \
  836. --generate-config
  837. This config can be edited if desired, for example to specify a different SSL
  838. certificate to use. Once done you can run the home server using::
  839. $ python synapse/app/homeserver.py --config-path homeserver.config
  840. See the README.rst for more information.
  841. Also note that some config options have been renamed, including:
  842. - "host" to "server-name"
  843. - "database" to "database-path"
  844. - "port" to "bind-port" and "unsecure-port"
  845. Upgrading to v0.0.1
  846. ===================
  847. This release completely changes the database schema and so requires upgrading
  848. it before starting the new version of the homeserver.
  849. The script "database-prepare-for-0.0.1.sh" should be used to upgrade the
  850. database. This will save all user information, such as logins and profiles,
  851. but will otherwise purge the database. This includes messages, which
  852. rooms the home server was a member of and room alias mappings.
  853. Before running the command the homeserver should be first completely
  854. shutdown. To run it, simply specify the location of the database, e.g.:
  855. ./scripts/database-prepare-for-0.0.1.sh "homeserver.db"
  856. Once this has successfully completed it will be safe to restart the
  857. homeserver. You may notice that the homeserver takes a few seconds longer to
  858. restart than usual as it reinitializes the database.
  859. On startup of the new version, users can either rejoin remote rooms using room
  860. aliases or by being reinvited. Alternatively, if any other homeserver sends a
  861. message to a room that the homeserver was previously in the local HS will
  862. automatically rejoin the room.