kamax-matrix / mxisd

Federated Matrix Identity Server
GNU Affero General Public License v3.0
223 stars 115 forks source link

unable to invite non-registered users for some email ids #43

Closed Rohithzr closed 6 years ago

Rohithzr commented 6 years ago

Description

I am trying to invite a user that has no entry in the database. I am able to invite most email ids but I cannot invite users with some email ids like:

In the issue https://github.com/matrix-org/synapse/issues/2740 I think it might be an issue for kamax mxisd and not just synapse, so I have referenced both the issues to each other.

These don't work sales@opensound.com talk2rohithzr@gmail.com

These work support@opensound.com nigharsh@gmail.com

The URL that is called

https://myHSandISdomain.com/_matrix/client/r0/rooms/!PCxVrQnBCfwqiHRfVu:idigid.com/invite?access_token=Mtoken

Request Params

id_server | idigid.com
medium | email
address | sales@opensound.com

Response Error (Status:500)

{"errcode":"M_UNKNOWN","error":"Internal server error"}

Logs (homeserver)

2017-12-19 12:00:26,075 - synapse.access.http.8008 - 59 - INFO - POST-7794- 34.214.200.51 - 8008 - Received request: POST /_matrix/client/r0/rooms/!PCxVrQnBCfwqiHRfVu%3Aidigid.com/invite?access_token=<redacted>
2017-12-19 12:00:26,076 - synapse.http.client - 96 - INFO - POST-7794- Sending request GET https://idigid.com/_matrix/identity/api/v1/lookup?medium=email&address=talk2rohithzr%40gmail.com
2017-12-19 12:00:26,145 - twisted - 131 - INFO - - Starting factory _HTTP11ClientFactory(<function quiescentCallback at 0x7fbb7926a398>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7fbb7911a210>)
2017-12-19 12:00:26,147 - synapse.metrics - 162 - INFO - - Collecting gc 0
2017-12-19 12:00:26,152 - synapse.http.client - 105 - INFO - POST-7794- Received response to  GET https://idigid.com/_matrix/identity/api/v1/lookup?medium=email&address=talk2rohithzr%40gmail.com: 200
2017-12-19 12:00:26,153 - synapse.http.client - 96 - INFO - POST-7794- Sending request POST https://idigid.com/_matrix/identity/api/v1/store-invite
2017-12-19 12:00:26,163 - twisted - 131 - INFO - POST-7794- Stopping factory _HTTP11ClientFactory(<function quiescentCallback at 0x7fbb7926a398>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7fbb7911a210>)
2017-12-19 12:00:26,164 - twisted - 131 - INFO - POST-7794- Starting factory _HTTP11ClientFactory(<function quiescentCallback at 0x7fbb79345f50>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7fbb7911db50>)
2017-12-19 12:00:26,598 - synapse.http.client - 105 - INFO - POST-7794- Received response to  POST https://idigid.com/_matrix/identity/api/v1/store-invite: 400
2017-12-19 12:00:26,599 - synapse.http.server - 139 - ERROR - POST-7794- Failed handle request synapse.http.server._async_render on <synapse.rest.ClientRestResource object at 0x7fbb89d5c910>: <XForwardedForRequest at 0x7fbb790603b0 method=POST uri=/_matrix/client/r0/rooms/!PCxVrQnBCfwqiHRfVu%3Aidigid.com/invite?access_token=<redacted> clientproto=HTTP/1.0 site=8008>
Traceback (most recent call last):
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/synapse/http/server.py", line 116, in wrapped_request_handler
    yield request_handler(self, request, request_metrics)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/synapse/http/server.py", line 257, in _async_render
    callback_return = yield callback(request, **kwargs)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/synapse/rest/client/v1/room.py", line 603, in on_POST
    txn_id
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/synapse/handlers/room_member.py", line 533, in do_3pid_invite
    txn_id=txn_id
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/synapse/handlers/room_member.py", line 639, in _make_and_store_3pid_invite
    inviter_avatar_url=inviter_avatar_url
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1386, in _inlineCallbacks
    result = g.send(result)
  File "/home/ubuntu/.synapse/local/lib/python2.7/site-packages/synapse/handlers/room_member.py", line 745, in _ask_id_server_for_third_party_invite
    token = data["token"]
KeyError: 'token'
2017-12-19 12:00:26,600 - synapse.access.http.8008 - 91 - INFO - POST-7794- 34.214.200.51 - 8008 - {@ro_zivo:idigid.com} Processed request: 525ms (12ms, 0ms) (0ms/0) 67B 500 "POST /_matrix/client/r0/rooms/!PCxVrQnBCfwqiHRfVu%3Aidigid.com/invite?access_token=<redacted> HTTP/1.0" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0"
2017-12-19 12:00:26,600 - twisted - 131 - INFO - POST-7794- Stopping factory _HTTP11ClientFactory(<function quiescentCallback at 0x7fbb79345f50>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7fbb7911db50>)
maxidorius commented 6 years ago

I need the mxisd logs also for this action.

Rohithzr commented 6 years ago

mxisd logs of the same error

Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .455  INFO [nio-8090-exec-7]  i.k.m.invitation.InvitationManager : Handling invite for email:talk2rohithzr@gmail.com from @ro_zivo:idigid.com in room !PCxVrQnBCfwqiHRfVu:idigid.com
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .455  INFO [nio-8090-exec-7] l.s.RecursivePriorityLookupStrategy : Host Internal allowed for recursion: true
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .455  INFO [nio-8090-exec-7]  i.k.m.l.provider.DnsLookupProvider : Performing DNS lookup for talk2rohithzr@gmail.com
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .455  INFO [nio-8090-exec-7]  i.k.m.l.provider.DnsLookupProvider : Domain name for talk2rohithzr@gmail.com: gmail.com
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .455  INFO [nio-8090-exec-7]    i.k.m.matrix.IdentityServerUtils : gmail.com is not an URL, using as-is
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .455  INFO [nio-8090-exec-7]    i.k.m.matrix.IdentityServerUtils : Discovery Identity Server for gmail.com
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .455  INFO [nio-8090-exec-7]    i.k.m.matrix.IdentityServerUtils : Performing SRV lookup
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .455  INFO [nio-8090-exec-7]    i.k.m.matrix.IdentityServerUtils : Lookup name: _matrix-identity._tcp.gmail.com
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .456  INFO [nio-8090-exec-7]    i.k.m.matrix.IdentityServerUtils : No SRV record for _matrix-identity._tcp.gmail.com
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .456  INFO [nio-8090-exec-7]    i.k.m.matrix.IdentityServerUtils : Performing basic lookup using domain name gmail.com
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .529  INFO [nio-8090-exec-7]    i.k.m.matrix.IdentityServerUtils : Usability of https://gmail.com as Identity server: answer status: 404
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .529  INFO [nio-8090-exec-7]    i.k.m.matrix.IdentityServerUtils : https://gmail.com is not a usable Identity Server
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .529  INFO [nio-8090-exec-7] k.m.l.p.RemoteIdentityServerFetcher : Looking up email 3PID talk2rohithzr@gmail.com using https://matrix.org
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .899  INFO [nio-8090-exec-7] k.m.l.p.RemoteIdentityServerFetcher : Found 3PID mapping: {"medium":"email","not_after":4663606263261,"ts":1510006263261,"signatures":{"matrix.org":{"ed25519:0":"xaJC2SQ8xHe7xBI6y4obFUp+uGCNxX16haKVjf5O0F+muTFFbJwWKc9nrW7iSs8jEo0Z4dUC+o4hHd9Jde/pDg"},"vector.im":{"ed25519:0":"YynXiT2h5uL7lYQoHq9Eq3VgxySHxwMJBCcKQlzh7p1P2Z9/V8GCkl+3SiWoYNcnPV5BdkMviPWi4DhRq6N8Aw"}},"address":"talk2rohithzr@gmail.com","mxid":"@opbio_test:idigid.com","not_before":1510006263261}
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .899  INFO [nio-8090-exec-7]  i.k.m.invitation.InvitationManager : Mapping for email:talk2rohithzr@gmail.com already exists, refusing to store invite
Dec 19 14:30:56 ip-172-31-19-34 mxisd.jar[12942]: .899  INFO [nio-8090-exec-7]     i.k.m.c.DefaultExceptionHandler : Request POST http://localhost:8090/_matrix/identity/api/v1/store-invite - Error M_ALREADY_EXISTS: A mapping already exists for this 3PID
maxidorius commented 6 years ago

It's a synapse's bug. a 3PID mapping already exists for those emails, so mxisd is refusing to store the invite. synapse should not have send the invite and invited by Matrix ID instead. synapse also fails to handle the correct (as per specification) error for it.

Rohithzr commented 6 years ago

there is no entry in the user_threepids or users table in my database. both synapse and mxisd are using the same database. so where can this possibly be stored

maxidorius commented 6 years ago
Dec 19 14:30:56 ..  INFO [..] k.m.l.p.RemoteIdentityServerFetcher : Looking up email 3PID talk2rohithzr@gmail.com using https://matrix.org
Dec 19 14:30:56 ..  INFO [..] k.m.l.p.RemoteIdentityServerFetcher : Found 3PID mapping: {"medium":"email","not_after":4663606263261,"ts":1510006263261,"signatures":{"matrix.org":{"ed25519:0":"xaJC2SQ8xHe7xBI6y4obFUp+uGCNxX16haKVjf5O0F+muTFFbJwWKc9nrW7iSs8jEo0Z4dUC+o4hHd9Jde/pDg"},"vector.im":{"ed25519:0":"YynXiT2h5uL7lYQoHq9Eq3VgxySHxwMJBCcKQlzh7p1P2Z9/V8GCkl+3SiWoYNcnPV5BdkMviPWi4DhRq6N8Aw"}},"address":"talk2rohithzr@gmail.com","mxid":"@opbio_test:idigid.com","not_before":1510006263261}

on the Identity server of Matrix.org

Rohithzr commented 6 years ago

ok in the homeserver.yaml i find this line

# The trusted servers to download signing keys from.
perspectives:
  servers:
    "matrix.org":
      verify_keys:
        "ed25519:auto":
          key: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw"

should I be pointing this to mxisd? if yes will it be the same key as given here?

maxidorius commented 6 years ago

that is absolutely not related to Identity, or mxisd. Your problem is a synapse bug. As for the identity data on Matrix.org, you'll need to talk with them to remove it as you can't do that on your own currently.