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

Commit f81d02d

Browse files
committed
Merge tag 'v1.26.0rc1' into develop
Synapse 1.26.0rc1 (2021-01-20) ============================== This release brings a new schema version for Synapse and rolling back to a previous verious is not trivial. Please review [UPGRADE.rst](UPGRADE.rst) for more details on these changes and for general upgrade guidance. Features -------- - Add support for multiple SSO Identity Providers. ([\#9015](#9015), [\#9017](#9017), [\#9036](#9036), [\#9067](#9067), [\#9081](#9081), [\#9082](#9082), [\#9105](#9105), [\#9107](#9107), [\#9109](#9109), [\#9110](#9110), [\#9127](#9127), [\#9153](#9153), [\#9154](#9154), [\#9177](#9177)) - During user-interactive authentication via single-sign-on, give a better error if the user uses the wrong account on the SSO IdP. ([\#9091](#9091)) - Give the `public_baseurl` a default value, if it is not explicitly set in the configuration file. ([\#9159](#9159)) - Improve performance when calculating ignored users in large rooms. ([\#9024](#9024)) - Implement [MSC2176](matrix-org/matrix-spec-proposals#2176) in an experimental room version. ([\#8984](#8984)) - Add an admin API for protecting local media from quarantine. ([\#9086](#9086)) - Remove a user's avatar URL and display name when deactivated with the Admin API. ([\#8932](#8932)) - Update `/_synapse/admin/v1/users/<user_id>/joined_rooms` to work for both local and remote users. ([\#8948](#8948)) - Add experimental support for handling to-device messages on worker processes. ([\#9042](#9042), [\#9043](#9043), [\#9044](#9044), [\#9130](#9130)) - Add experimental support for handling `/keys/claim` and `/room_keys` APIs on worker processes. ([\#9068](#9068)) - Add experimental support for handling `/devices` API on worker processes. ([\#9092](#9092)) - Add experimental support for moving off receipts and account data persistence off master. ([\#9104](#9104), [\#9166](#9166)) Bugfixes -------- - Fix a long-standing issue where an internal server error would occur when requesting a profile over federation that did not include a display name / avatar URL. ([\#9023](#9023)) - Fix a long-standing bug where some caches could grow larger than configured. ([\#9028](#9028)) - Fix error handling during insertion of client IPs into the database. ([\#9051](#9051)) - Fix bug where we didn't correctly record CPU time spent in `on_new_event` block. ([\#9053](#9053)) - Fix a minor bug which could cause confusing error messages from invalid configurations. ([\#9054](#9054)) - Fix incorrect exit code when there is an error at startup. ([\#9059](#9059)) - Fix `JSONDecodeError` spamming the logs when sending transactions to remote servers. ([\#9070](#9070)) - Fix "Failed to send request" errors when a client provides an invalid room alias. ([\#9071](#9071)) - Fix bugs in federation catchup logic that caused outbound federation to be delayed for large servers after start up. Introduced in v1.8.0 and v1.21.0. ([\#9114](#9114), [\#9116](#9116)) - Fix corruption of `pushers` data when a postgres bouncer is used. ([\#9117](#9117)) - Fix minor bugs in handling the `clientRedirectUrl` parameter for SSO login. ([\#9128](#9128)) - Fix "Unhandled error in Deferred: BodyExceededMaxSize" errors when .well-known files that are too large. ([\#9108](#9108)) - Fix "UnboundLocalError: local variable 'length' referenced before assignment" errors when the response body exceeds the expected size. This bug was introduced in v1.25.0. ([\#9145](#9145)) - Fix a long-standing bug "ValueError: invalid literal for int() with base 10" when `/publicRooms` is requested with an invalid `server` parameter. ([\#9161](#9161)) Improved Documentation ---------------------- - Add some extra docs for getting Synapse running on macOS. ([\#8997](#8997)) - Correct a typo in the `systemd-with-workers` documentation. ([\#9035](#9035)) - Correct a typo in `INSTALL.md`. ([\#9040](#9040)) - Add missing `user_mapping_provider` configuration to the Keycloak OIDC example. Contributed by @chris-ruecker. ([\#9057](#9057)) - Quote `pip install` packages when extras are used to avoid shells interpreting bracket characters. ([\#9151](#9151)) Deprecations and Removals ------------------------- - Remove broken and unmaintained `demo/webserver.py` script. ([\#9039](#9039)) Internal Changes ---------------- - Improve efficiency of large state resolutions. ([\#8868](#8868), [\#9029](#9029), [\#9115](#9115), [\#9118](#9118), [\#9124](#9124)) - Various clean-ups to the structured logging and logging context code. ([\#8939](#8939)) - Ensure rejected events get added to some metadata tables. ([\#9016](#9016)) - Ignore date-rotated homeserver logs saved to disk. ([\#9018](#9018)) - Remove an unused column from `access_tokens` table. ([\#9025](#9025)) - Add a `-noextras` factor to `tox.ini`, to support running the tests with no optional dependencies. ([\#9030](#9030)) - Fix running unit tests when optional dependencies are not installed. ([\#9031](#9031)) - Allow bumping schema version when using split out state database. ([\#9033](#9033)) - Configure the linters to run on a consistent set of files. ([\#9038](#9038)) - Various cleanups to device inbox store. ([\#9041](#9041)) - Drop unused database tables. ([\#9055](#9055)) - Remove unused `SynapseService` class. ([\#9058](#9058)) - Remove unnecessary declarations in the tests for the admin API. ([\#9063](#9063)) - Remove `SynapseRequest.get_user_agent`. ([\#9069](#9069)) - Remove redundant `Homeserver.get_ip_from_request` method. ([\#9080](#9080)) - Add type hints to media repository. ([\#9093](#9093)) - Fix the wrong arguments being passed to `BlacklistingAgentWrapper` from `MatrixFederationAgent`. Contributed by Timothy Leung. ([\#9098](#9098)) - Reduce the scope of caught exceptions in `BlacklistingAgentWrapper`. ([\#9106](#9106)) - Improve `UsernamePickerTestCase`. ([\#9112](#9112)) - Remove dependency on `distutils`. ([\#9125](#9125)) - Enforce that replication HTTP clients are called with keyword arguments only. ([\#9144](#9144)) - Fix the Python 3.5 / old dependencies build in CI. ([\#9146](#9146)) - Replace the old `perspectives` option in the Synapse docker config file template with `trusted_key_servers`. ([\#9157](#9157))
2 parents 620ecf1 + adabf32 commit f81d02d

File tree

21 files changed

+210
-96
lines changed

21 files changed

+210
-96
lines changed

CHANGES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
Synapse 1.26.0rc1 (2021-01-20)
22
==============================
33

4+
This release brings a new schema version for Synapse and rolling back to a previous
5+
verious is not trivial. Please review [UPGRADE.rst](UPGRADE.rst) for more details
6+
on these changes and for general upgrade guidance.
7+
48
Features
59
--------
610

7-
- Add support for multiple SSO Identity Providers. ([\#9015](https://github.com/matrix-org/synapse/issues/9015), [\#9017](https://github.com/matrix-org/synapse/issues/9017), [\#9036](https://github.com/matrix-org/synapse/issues/9036), [\#9067](https://github.com/matrix-org/synapse/issues/9067), [\#9081](https://github.com/matrix-org/synapse/issues/9081), [\#9082](https://github.com/matrix-org/synapse/issues/9082), [\#9105](https://github.com/matrix-org/synapse/issues/9105), [\#9107](https://github.com/matrix-org/synapse/issues/9107), [\#9109](https://github.com/matrix-org/synapse/issues/9109), [\#9110](https://github.com/matrix-org/synapse/issues/9110), [\#9127](https://github.com/matrix-org/synapse/issues/9127), [\#9153](https://github.com/matrix-org/synapse/issues/9153))
11+
- Add support for multiple SSO Identity Providers. ([\#9015](https://github.com/matrix-org/synapse/issues/9015), [\#9017](https://github.com/matrix-org/synapse/issues/9017), [\#9036](https://github.com/matrix-org/synapse/issues/9036), [\#9067](https://github.com/matrix-org/synapse/issues/9067), [\#9081](https://github.com/matrix-org/synapse/issues/9081), [\#9082](https://github.com/matrix-org/synapse/issues/9082), [\#9105](https://github.com/matrix-org/synapse/issues/9105), [\#9107](https://github.com/matrix-org/synapse/issues/9107), [\#9109](https://github.com/matrix-org/synapse/issues/9109), [\#9110](https://github.com/matrix-org/synapse/issues/9110), [\#9127](https://github.com/matrix-org/synapse/issues/9127), [\#9153](https://github.com/matrix-org/synapse/issues/9153), [\#9154](https://github.com/matrix-org/synapse/issues/9154), [\#9177](https://github.com/matrix-org/synapse/issues/9177))
812
- During user-interactive authentication via single-sign-on, give a better error if the user uses the wrong account on the SSO IdP. ([\#9091](https://github.com/matrix-org/synapse/issues/9091))
13+
- Give the `public_baseurl` a default value, if it is not explicitly set in the configuration file. ([\#9159](https://github.com/matrix-org/synapse/issues/9159))
914
- Improve performance when calculating ignored users in large rooms. ([\#9024](https://github.com/matrix-org/synapse/issues/9024))
1015
- Implement [MSC2176](https://github.com/matrix-org/matrix-doc/pull/2176) in an experimental room version. ([\#8984](https://github.com/matrix-org/synapse/issues/8984))
1116
- Add an admin API for protecting local media from quarantine. ([\#9086](https://github.com/matrix-org/synapse/issues/9086))

UPGRADE.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,56 @@ for example:
8585
wget https://packages.matrix.org/debian/pool/main/m/matrix-synapse-py3/matrix-synapse-py3_1.3.0+stretch1_amd64.deb
8686
dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
8787
88+
Upgrading to v1.26.0
89+
====================
90+
91+
Rolling back to v1.25.0 after a failed upgrade
92+
----------------------------------------------
93+
94+
v1.26.0 includes a lot of large changes. If something problematic occurs, you
95+
may want to roll-back to a previous version of Synapse. Because v1.26.0 also
96+
includes a new database schema version, reverting that version is also required
97+
alongside the generic rollback instructions mentioned above. In short, to roll
98+
back to v1.25.0 you need to:
99+
100+
1. Stop the server
101+
2. Decrease the schema version in the database:
102+
103+
.. code:: sql
104+
105+
UPDATE schema_version SET version = 58;
106+
107+
3. Delete the ignored users & chain cover data:
108+
109+
.. code:: sql
110+
111+
DROP TABLE IF EXISTS ignored_users;
112+
UPDATE rooms SET has_auth_chain_index = false;
113+
114+
For PostgreSQL run:
115+
116+
.. code:: sql
117+
118+
TRUNCATE event_auth_chain_links;
119+
TRUNCATE event_auth_chains;
120+
121+
For SQLite run:
122+
123+
.. code:: sql
124+
125+
DELETE FROM event_auth_chain_links;
126+
DELETE FROM event_auth_chains;
127+
128+
4. Mark the deltas as not run (so they will re-run on upgrade).
129+
130+
.. code:: sql
131+
132+
DELETE FROM applied_schema_deltas WHERE version = 59 AND file = "59/01ignored_user.py";
133+
DELETE FROM applied_schema_deltas WHERE version = 59 AND file = "59/06chain_cover_index.sql";
134+
135+
5. Downgrade Synapse by following the instructions for your installation method
136+
in the "Rolling back to older versions" section above.
137+
88138
Upgrading to v1.25.0
89139
====================
90140

changelog.d/9159.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/sample_config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,10 @@ saml2_config:
17261726
# idp_name: A user-facing name for this identity provider, which is used to
17271727
# offer the user a choice of login mechanisms.
17281728
#
1729+
# idp_icon: An optional icon for this identity provider, which is presented
1730+
# by identity picker pages. If given, must be an MXC URI of the format
1731+
# mxc://<server-name>/<media-id>
1732+
#
17291733
# discover: set to 'false' to disable the use of the OIDC discovery mechanism
17301734
# to discover endpoints. Defaults to true.
17311735
#

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ files =
100100
synapse/util/async_helpers.py,
101101
synapse/util/caches,
102102
synapse/util/metrics.py,
103+
synapse/util/stringutils.py,
103104
tests/replication,
104105
tests/test_utils,
105106
tests/handlers/test_password_providers.py,

synapse/config/oidc_config.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from synapse.python_dependencies import DependencyException, check_requirements
2424
from synapse.types import Collection, JsonDict
2525
from synapse.util.module_loader import load_module
26+
from synapse.util.stringutils import parse_and_validate_mxc_uri
2627

2728
from ._base import Config, ConfigError
2829

@@ -66,6 +67,10 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
6667
# idp_name: A user-facing name for this identity provider, which is used to
6768
# offer the user a choice of login mechanisms.
6869
#
70+
# idp_icon: An optional icon for this identity provider, which is presented
71+
# by identity picker pages. If given, must be an MXC URI of the format
72+
# mxc://<server-name>/<media-id>
73+
#
6974
# discover: set to 'false' to disable the use of the OIDC discovery mechanism
7075
# to discover endpoints. Defaults to true.
7176
#
@@ -207,6 +212,7 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
207212
"properties": {
208213
"idp_id": {"type": "string", "minLength": 1, "maxLength": 128},
209214
"idp_name": {"type": "string"},
215+
"idp_icon": {"type": "string"},
210216
"discover": {"type": "boolean"},
211217
"issuer": {"type": "string"},
212218
"client_id": {"type": "string"},
@@ -325,20 +331,37 @@ def _parse_oidc_config_dict(
325331
config_path + ("user_mapping_provider", "module"),
326332
)
327333

328-
# MSC2858 will appy certain limits in what can be used as an IdP id, so let's
334+
# MSC2858 will apply certain limits in what can be used as an IdP id, so let's
329335
# enforce those limits now.
336+
# TODO: factor out this stuff to a generic function
330337
idp_id = oidc_config.get("idp_id", "oidc")
331-
valid_idp_chars = set(string.ascii_letters + string.digits + "-._~")
338+
valid_idp_chars = set(string.ascii_lowercase + string.digits + "-._")
332339

333340
if any(c not in valid_idp_chars for c in idp_id):
334341
raise ConfigError(
335-
'idp_id may only contain A-Z, a-z, 0-9, "-", ".", "_", "~"',
342+
'idp_id may only contain a-z, 0-9, "-", ".", "_"',
336343
config_path + ("idp_id",),
337344
)
338345

346+
if idp_id[0] not in string.ascii_lowercase:
347+
raise ConfigError(
348+
"idp_id must start with a-z", config_path + ("idp_id",),
349+
)
350+
351+
# MSC2858 also specifies that the idp_icon must be a valid MXC uri
352+
idp_icon = oidc_config.get("idp_icon")
353+
if idp_icon is not None:
354+
try:
355+
parse_and_validate_mxc_uri(idp_icon)
356+
except ValueError as e:
357+
raise ConfigError(
358+
"idp_icon must be a valid MXC URI", config_path + ("idp_icon",)
359+
) from e
360+
339361
return OidcProviderConfig(
340362
idp_id=idp_id,
341363
idp_name=oidc_config.get("idp_name", "OIDC"),
364+
idp_icon=idp_icon,
342365
discover=oidc_config.get("discover", True),
343366
issuer=oidc_config["issuer"],
344367
client_id=oidc_config["client_id"],
@@ -366,6 +389,9 @@ class OidcProviderConfig:
366389
# user-facing name for this identity provider.
367390
idp_name = attr.ib(type=str)
368391

392+
# Optional MXC URI for icon for this IdP.
393+
idp_icon = attr.ib(type=Optional[str])
394+
369395
# whether the OIDC discovery mechanism is used to discover endpoints
370396
discover = attr.ib(type=bool)
371397

synapse/config/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from netaddr import IPSet
2727

2828
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
29-
from synapse.http.endpoint import parse_and_validate_server_name
29+
from synapse.util.stringutils import parse_and_validate_server_name
3030

3131
from ._base import Config, ConfigError
3232

synapse/federation/federation_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
from synapse.federation.federation_base import FederationBase, event_from_pdu_json
5050
from synapse.federation.persistence import TransactionActions
5151
from synapse.federation.units import Edu, Transaction
52-
from synapse.http.endpoint import parse_server_name
5352
from synapse.http.servlet import assert_params_in_dict
5453
from synapse.logging.context import (
5554
make_deferred_yieldable,
@@ -66,6 +65,7 @@
6665
from synapse.util import glob_to_regex, json_decoder, unwrapFirstError
6766
from synapse.util.async_helpers import Linearizer, concurrently_execute
6867
from synapse.util.caches.response_cache import ResponseCache
68+
from synapse.util.stringutils import parse_server_name
6969

7070
if TYPE_CHECKING:
7171
from synapse.server import HomeServer

synapse/federation/transport/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
FEDERATION_V1_PREFIX,
2929
FEDERATION_V2_PREFIX,
3030
)
31-
from synapse.http.endpoint import parse_and_validate_server_name
3231
from synapse.http.server import JsonResource
3332
from synapse.http.servlet import (
3433
parse_boolean_from_args,
@@ -45,6 +44,7 @@
4544
)
4645
from synapse.server import HomeServer
4746
from synapse.types import ThirdPartyInstanceID, get_domain_from_id
47+
from synapse.util.stringutils import parse_and_validate_server_name
4848
from synapse.util.versionstring import get_version_string
4949

5050
logger = logging.getLogger(__name__)

synapse/handlers/cas_handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def __init__(self, hs: "HomeServer"):
8080
# user-facing name of this auth provider
8181
self.idp_name = "CAS"
8282

83+
# we do not currently support icons for CAS auth, but this is required by
84+
# the SsoIdentityProvider protocol type.
85+
self.idp_icon = None
86+
8387
self._sso_handler = hs.get_sso_handler()
8488

8589
self._sso_handler.register_identity_provider(self)

synapse/handlers/oidc_handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ def __init__(
271271
# user-facing name of this auth provider
272272
self.idp_name = provider.idp_name
273273

274+
# MXC URI for icon for this auth provider
275+
self.idp_icon = provider.idp_icon
276+
274277
self._sso_handler = hs.get_sso_handler()
275278

276279
self._sso_handler.register_identity_provider(self)

synapse/handlers/room.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS, RoomVersion
3939
from synapse.events import EventBase
4040
from synapse.events.utils import copy_power_levels_contents
41-
from synapse.http.endpoint import parse_and_validate_server_name
4241
from synapse.storage.state import StateFilter
4342
from synapse.types import (
4443
JsonDict,
@@ -55,6 +54,7 @@
5554
from synapse.util import stringutils
5655
from synapse.util.async_helpers import Linearizer
5756
from synapse.util.caches.response_cache import ResponseCache
57+
from synapse.util.stringutils import parse_and_validate_server_name
5858
from synapse.visibility import filter_events_for_client
5959

6060
from ._base import BaseHandler

synapse/handlers/saml_handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def __init__(self, hs: "HomeServer"):
7878
# user-facing name of this auth provider
7979
self.idp_name = "SAML"
8080

81+
# we do not currently support icons for SAML auth, but this is required by
82+
# the SsoIdentityProvider protocol type.
83+
self.idp_icon = None
84+
8185
# a map from saml session id to Saml2SessionData object
8286
self._outstanding_requests_dict = {} # type: Dict[str, Saml2SessionData]
8387

synapse/handlers/sso.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ def idp_id(self) -> str:
7575
def idp_name(self) -> str:
7676
"""User-facing name for this provider"""
7777

78+
@property
79+
def idp_icon(self) -> Optional[str]:
80+
"""Optional MXC URI for user-facing icon"""
81+
return None
82+
7883
@abc.abstractmethod
7984
async def handle_redirect_request(
8085
self,

synapse/http/endpoint.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

synapse/res/templates/sso_login_idp_picker.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ <h1 id="title">{{server_name | e}} Login</h1>
1717
<li>
1818
<input type="radio" name="idp" id="prov{{loop.index}}" value="{{p.idp_id}}">
1919
<label for="prov{{loop.index}}">{{p.idp_name | e}}</label>
20+
{% if p.idp_icon %}
21+
<img src="{{p.idp_icon | mxc_to_http(32, 32)}}"/>
22+
{% endif %}
2023
</li>
2124
{% endfor %}
2225
</ul>

synapse/rest/client/v1/room.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
)
3333
from synapse.api.filtering import Filter
3434
from synapse.events.utils import format_event_for_client_v2
35-
from synapse.http.endpoint import parse_and_validate_server_name
3635
from synapse.http.servlet import (
3736
RestServlet,
3837
assert_params_in_dict,
@@ -47,7 +46,7 @@
4746
from synapse.streams.config import PaginationConfig
4847
from synapse.types import RoomAlias, RoomID, StreamToken, ThirdPartyInstanceID, UserID
4948
from synapse.util import json_decoder
50-
from synapse.util.stringutils import random_string
49+
from synapse.util.stringutils import parse_and_validate_server_name, random_string
5150

5251
if TYPE_CHECKING:
5352
import synapse.server

0 commit comments

Comments
 (0)