diff --git a/synapse/api/urls.py b/synapse/api/urls.py
index e33ea0cf65..cb71d80875 100644
--- a/synapse/api/urls.py
+++ b/synapse/api/urls.py
@@ -33,7 +33,6 @@ CONTENT_REPO_PREFIX = "/_matrix/content"
SERVER_KEY_V2_PREFIX = "/_matrix/key/v2"
MEDIA_PREFIX = "/_matrix/media/r0"
LEGACY_MEDIA_PREFIX = "/_matrix/media/v1"
-IDENTITY_PREFIX = "/_matrix/identity/api/v1"
class ConsentURIBuilder(object):
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index 06aa582129..79be977ea6 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -40,7 +40,6 @@ from synapse import events
from synapse.api.urls import (
CONTENT_REPO_PREFIX,
FEDERATION_PREFIX,
- IDENTITY_PREFIX,
LEGACY_MEDIA_PREFIX,
MEDIA_PREFIX,
SERVER_KEY_V2_PREFIX,
@@ -63,7 +62,6 @@ from synapse.python_dependencies import check_requirements
from synapse.replication.http import REPLICATION_PREFIX, ReplicationRestResource
from synapse.replication.tcp.resource import ReplicationStreamProtocolFactory
from synapse.rest import ClientRestResource
-from synapse.rest.identity.v1 import IdentityApiV1Resource
from synapse.rest.key.v2 import KeyApiV2Resource
from synapse.rest.media.v0.content_repository import ContentRepoResource
from synapse.rest.well_known import WellKnownResource
@@ -229,9 +227,6 @@ class SynapseHomeServer(HomeServer):
"'media' resource conflicts with enable_media_repo=False",
)
- if name in ["identity"]:
- resources[IDENTITY_PREFIX] = IdentityApiV1Resource(self)
-
if name in ["keys", "federation"]:
resources[SERVER_KEY_V2_PREFIX] = KeyApiV2Resource(self)
diff --git a/synapse/config/server.py b/synapse/config/server.py
index ac44b17a09..c5e5679d52 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -573,7 +573,6 @@ KNOWN_RESOURCES = (
'replication',
'static',
'webclient',
- 'identity',
)
diff --git a/synapse/rest/client/v2_alpha/account.py b/synapse/rest/client/v2_alpha/account.py
index 7e5884df0c..752ea265bd 100644
--- a/synapse/rest/client/v2_alpha/account.py
+++ b/synapse/rest/client/v2_alpha/account.py
@@ -480,6 +480,38 @@ class ThreepidDeleteRestServlet(RestServlet):
)
+class ThreepidLookupRestServlet(RestServlet):
+ PATTERNS = client_v2_patterns("/account/3pid/lookup$")
+
+ def __init__(self, hs):
+ super(ThreepidLookupRestServlet, self).__init__()
+ self.config = hs.config
+ self.auth = hs.get_auth()
+ self.identity_handler = IdentityHandler(hs)
+
+ @defer.inlineCallbacks
+ def on_GET(self, request):
+ """Proxy a /_matrix/identity/api/v1/lookup request to an identity
+ server
+ """
+ yield self.auth.get_user_by_req(request)
+
+ # Extract query parameters
+ query_params = request.args
+ assert_params_in_dict(query_params, [b"medium", b"address", b"id_server"])
+
+ # Retrieve address and medium from the request parameters
+ medium = parse_string(request, "medium")
+ address = parse_string(request, "address")
+ id_server = parse_string(request, "id_server")
+
+ # Proxy the request to the identity server. lookup_3pid handles checking
+ # if the lookup is allowed so we don't need to do it here.
+ ret = yield self.identity_handler.lookup_3pid(id_server, medium, address)
+
+ respond_with_json(200, ret)
+
+
class WhoamiRestServlet(RestServlet):
PATTERNS = client_v2_patterns("/account/whoami$")
diff --git a/synapse/rest/identity/__init__.py b/synapse/rest/identity/__init__.py
deleted file mode 100644
index 1453d04571..0000000000
--- a/synapse/rest/identity/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2019 New Vector Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
diff --git a/synapse/rest/identity/v1/__init__.py b/synapse/rest/identity/v1/__init__.py
deleted file mode 100644
index 09057ea16b..0000000000
--- a/synapse/rest/identity/v1/__init__.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2019 New Vector Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from twisted.web.resource import Resource
-
-from .lookup import IdentityLookup
-
-
-class IdentityApiV1Resource(Resource):
- def __init__(self, hs):
- Resource.__init__(self)
- self.putChild(b"lookup", IdentityLookup(hs))
diff --git a/synapse/rest/identity/v1/lookup.py b/synapse/rest/identity/v1/lookup.py
deleted file mode 100644
index c2d18fbb63..0000000000
--- a/synapse/rest/identity/v1/lookup.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2019 New Vector Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-import logging
-
-from twisted.internet import defer
-from twisted.web.resource import Resource
-from twisted.web.server import NOT_DONE_YET
-
-from synapse.api.errors import SynapseError
-from synapse.handlers.identity import IdentityHandler
-from synapse.http.server import respond_with_json, wrap_json_request_handler
-from synapse.http.servlet import assert_params_in_dict, parse_string
-
-logger = logging.getLogger(__name__)
-
-
-class IdentityLookup(Resource):
- isLeaf = True
-
- def __init__(self, hs):
- self.config = hs.config
- self.auth = hs.get_auth()
- self.identity_handler = IdentityHandler(hs)
- Resource.__init__(self)
-
- def render_GET(self, request):
- self.async_render_GET(request)
- return NOT_DONE_YET
-
- @wrap_json_request_handler
- @defer.inlineCallbacks
- def async_render_GET(self, request):
- """Proxy a /_matrix/identity/api/v1/lookup request to an identity
- server
- """
- yield self.auth.get_user_by_req(request, allow_guest=True)
-
- if not self.config.enable_3pid_lookup:
- raise SynapseError(
- 403,
- "Looking up third-party identifiers is denied from this server"
- )
-
- # Extract query parameters
- query_params = request.args
- assert_params_in_dict(query_params, [b"medium", b"address", b"is_server"])
-
- # Retrieve address and medium from the request parameters
- medium = parse_string(request, "medium")
- address = parse_string(request, "address")
- is_server = parse_string(request, "is_server")
-
- # Proxy the request to the identity server
- ret = yield self.identity_handler.lookup_3pid(is_server, medium, address)
-
- respond_with_json(request, 200, ret, send_cors=True)
|