lint
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
"""Utilities for interacting with Identity Servers"""
|
||||
|
||||
import logging
|
||||
from enum import Enum
|
||||
|
||||
from canonicaljson import json
|
||||
|
||||
@@ -31,7 +32,6 @@ from synapse.api.errors import (
|
||||
)
|
||||
|
||||
from ._base import BaseHandler
|
||||
from enum import Enum
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -284,6 +284,7 @@ class IdentityHandler(BaseHandler):
|
||||
logger.info("Proxied requestToken failed: %r", e)
|
||||
raise e.to_synapse_error()
|
||||
|
||||
|
||||
class LookupAlgorithm(Enum):
|
||||
"""
|
||||
Supported hashing algorithms when performing a 3PID lookup.
|
||||
@@ -292,5 +293,6 @@ class LookupAlgorithm(Enum):
|
||||
encoding
|
||||
NONE - Not performing any hashing. Simply sending an (address, medium) combo in plaintext
|
||||
"""
|
||||
|
||||
SHA256 = "sha256"
|
||||
NONE = "none"
|
||||
|
||||
@@ -29,6 +29,7 @@ from twisted.internet import defer
|
||||
from synapse import types
|
||||
from synapse.api.constants import EventTypes, Membership
|
||||
from synapse.api.errors import AuthError, Codes, HttpResponseException, SynapseError
|
||||
from synapse.handlers.identity import LookupAlgorithm
|
||||
from synapse.types import RoomID, UserID
|
||||
from synapse.util.async_helpers import Linearizer
|
||||
from synapse.util.distributor import user_joined_room, user_left_room
|
||||
@@ -36,12 +37,11 @@ from synapse.util.hash import sha256_and_url_safe_base64
|
||||
|
||||
from ._base import BaseHandler
|
||||
|
||||
from synapse.handlers.identity import LookupAlgorithm
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
id_server_scheme = "https://"
|
||||
|
||||
|
||||
class RoomMemberHandler(object):
|
||||
# TODO(paul): This handler currently contains a messy conflation of
|
||||
# low-level API that works on UserID objects and so on, and REST-level
|
||||
@@ -712,10 +712,14 @@ class RoomMemberHandler(object):
|
||||
return None
|
||||
|
||||
# Check if none of the supported lookup algorithms are present
|
||||
if not any(i in supported_lookup_algorithms for i in [LookupAlgorithm.SHA256,
|
||||
LookupAlgorithm.NONE]):
|
||||
logger.warn("No supported lookup algorithms found for %s%s" %
|
||||
(id_server_scheme, id_server))
|
||||
if not any(
|
||||
i in supported_lookup_algorithms
|
||||
for i in [LookupAlgorithm.SHA256, LookupAlgorithm.NONE]
|
||||
):
|
||||
logger.warn(
|
||||
"No supported lookup algorithms found for %s%s"
|
||||
% (id_server_scheme, id_server)
|
||||
)
|
||||
|
||||
return None
|
||||
|
||||
@@ -748,9 +752,8 @@ class RoomMemberHandler(object):
|
||||
return None
|
||||
|
||||
# Check for a mapping from what we looked up to an MXID
|
||||
if (
|
||||
"mappings" not in lookup_results
|
||||
or not isinstance(lookup_results["mappings"], dict)
|
||||
if "mappings" not in lookup_results or not isinstance(
|
||||
lookup_results["mappings"], dict
|
||||
):
|
||||
logger.debug("No results from 3pid lookup")
|
||||
return None
|
||||
@@ -758,7 +761,6 @@ class RoomMemberHandler(object):
|
||||
# Return the MXID if it's available, or None otherwise
|
||||
return lookup_results["mappings"].get(lookup_value)
|
||||
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _verify_any_signature(self, data, server_hostname):
|
||||
if server_hostname not in data["signatures"]:
|
||||
|
||||
@@ -18,6 +18,7 @@ import synapse.server_notices.server_notices_sender
|
||||
import synapse.state
|
||||
import synapse.storage
|
||||
|
||||
|
||||
class HomeServer(object):
|
||||
@property
|
||||
def config(self) -> synapse.config.homeserver.HomeServerConfig:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import hashlib
|
||||
|
||||
import unpaddedbase64
|
||||
|
||||
|
||||
@@ -30,4 +31,3 @@ def sha256_and_url_safe_base64(input_text):
|
||||
"""
|
||||
digest = hashlib.sha256(input_text.encode()).digest()
|
||||
return unpaddedbase64.encode_base64(digest, urlsafe=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user