UPGRADE.rst 47 KB

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