mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-09-19 01:54:37 -04:00
Merge remote-tracking branch 'upstream/release-v1.24.0'
This commit is contained in:
commit
8fe8d954bb
9 changed files with 81 additions and 18 deletions
|
@ -48,7 +48,7 @@ try:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
__version__ = "1.24.0rc1"
|
||||
__version__ = "1.24.0rc2"
|
||||
|
||||
if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)):
|
||||
# We import here so that we don't have to install a bunch of deps when
|
||||
|
|
|
@ -888,7 +888,7 @@ class OidcHandler(BaseHandler):
|
|||
# continue to already be in use. Note that the error raised is
|
||||
# arbitrary and will get turned into a MappingException.
|
||||
if failures:
|
||||
raise RuntimeError(
|
||||
raise MappingException(
|
||||
"Mapping provider does not support de-duplicating Matrix IDs"
|
||||
)
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ from typing import TYPE_CHECKING, Awaitable, Callable, List, Optional
|
|||
|
||||
import attr
|
||||
|
||||
from synapse.api.errors import RedirectException
|
||||
from synapse.handlers._base import BaseHandler
|
||||
from synapse.http.server import respond_with_html
|
||||
from synapse.types import UserID, contains_invalid_mxid_characters
|
||||
|
@ -28,7 +29,9 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class MappingException(Exception):
|
||||
"""Used to catch errors when mapping the UserInfo object
|
||||
"""Used to catch errors when mapping an SSO response to user attributes.
|
||||
|
||||
Note that the msg that is raised is shown to end-users.
|
||||
"""
|
||||
|
||||
|
||||
|
@ -145,6 +148,14 @@ class SsoHandler(BaseHandler):
|
|||
sso_to_matrix_id_mapper: A callable to generate the user attributes.
|
||||
The only parameter is an integer which represents the amount of
|
||||
times the returned mxid localpart mapping has failed.
|
||||
|
||||
It is expected that the mapper can raise two exceptions, which
|
||||
will get passed through to the caller:
|
||||
|
||||
MappingException if there was a problem mapping the response
|
||||
to the user.
|
||||
RedirectException to redirect to an additional page (e.g.
|
||||
to prompt the user for more information).
|
||||
grandfather_existing_users: A callable which can return an previously
|
||||
existing matrix ID. The SSO ID is then linked to the returned
|
||||
matrix ID.
|
||||
|
@ -154,8 +165,8 @@ class SsoHandler(BaseHandler):
|
|||
|
||||
Raises:
|
||||
MappingException if there was a problem mapping the response to a user.
|
||||
RedirectException: some mapping providers may raise this if they need
|
||||
to redirect to an interstitial page.
|
||||
RedirectException: if the mapping provider needs to redirect the user
|
||||
to an additional page. (e.g. to prompt for more information)
|
||||
|
||||
"""
|
||||
# first of all, check if we already have a mapping for this user
|
||||
|
@ -179,10 +190,16 @@ class SsoHandler(BaseHandler):
|
|||
for i in range(self._MAP_USERNAME_RETRIES):
|
||||
try:
|
||||
attributes = await sso_to_matrix_id_mapper(i)
|
||||
except (RedirectException, MappingException):
|
||||
# Mapping providers are allowed to issue a redirect (e.g. to ask
|
||||
# the user for more information) and can issue a mapping exception
|
||||
# if a name cannot be generated.
|
||||
raise
|
||||
except Exception as e:
|
||||
# Any other exception is unexpected.
|
||||
raise MappingException(
|
||||
"Could not extract user attributes from SSO response: " + str(e)
|
||||
)
|
||||
"Could not extract user attributes from SSO response."
|
||||
) from e
|
||||
|
||||
logger.debug(
|
||||
"Retrieved user attributes from user mapping provider: %r (attempt %d)",
|
||||
|
|
|
@ -40,6 +40,10 @@ logger = logging.getLogger(__name__)
|
|||
# Note that these both represent runtime dependencies (and the versions
|
||||
# installed are checked at runtime).
|
||||
#
|
||||
# Also note that we replicate these constraints in the Synapse Dockerfile while
|
||||
# pre-installing dependencies. If these constraints are updated here, the same
|
||||
# change should be made in the Dockerfile.
|
||||
#
|
||||
# [1] https://pip.pypa.io/en/stable/reference/pip_install/#requirement-specifiers.
|
||||
|
||||
REQUIREMENTS = [
|
||||
|
@ -69,14 +73,7 @@ REQUIREMENTS = [
|
|||
"msgpack>=0.5.2",
|
||||
"phonenumbers>=8.2.0",
|
||||
# we use GaugeHistogramMetric, which was added in prom-client 0.4.0.
|
||||
# prom-client has a history of breaking backwards compatibility between
|
||||
# minor versions (https://github.com/prometheus/client_python/issues/317),
|
||||
# so we also pin the minor version.
|
||||
#
|
||||
# Note that we replicate these constraints in the Synapse Dockerfile while
|
||||
# pre-installing dependencies. If these constraints are updated here, the
|
||||
# same change should be made in the Dockerfile.
|
||||
"prometheus_client>=0.4.0,<0.9.0",
|
||||
"prometheus_client>=0.4.0",
|
||||
# we use attr.validators.deep_iterable, which arrived in 19.1.0 (Note:
|
||||
# Fedora 31 only has 19.1, so if we want to upgrade we should wait until 33
|
||||
# is out in November.)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue