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

Commit

Permalink
Merge pull request #4757 from matrix-org/erikj/key_api_fed_readae
Browse files Browse the repository at this point in the history
Move server key queries to federation reader
  • Loading branch information
erikjohnston authored Feb 27, 2019
2 parents 7590e9f + d4dc527 commit 46b0151
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/4757.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move server key queries to federation reader.
1 change: 1 addition & 0 deletions docs/workers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ endpoints matching the following regular expressions::
^/_matrix/federation/v1/event_auth/
^/_matrix/federation/v1/exchange_third_party_invite/
^/_matrix/federation/v1/send/
^/_matrix/key/v2/query

The above endpoints should all be routed to the federation_reader worker by the
reverse-proxy configuration.
Expand Down
6 changes: 5 additions & 1 deletion synapse/app/federation_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import synapse
from synapse import events
from synapse.api.urls import FEDERATION_PREFIX
from synapse.api.urls import FEDERATION_PREFIX, SERVER_KEY_V2_PREFIX
from synapse.app import _base
from synapse.config._base import ConfigError
from synapse.config.homeserver import HomeServerConfig
Expand All @@ -44,6 +44,7 @@
from synapse.replication.slave.storage.room import RoomStore
from synapse.replication.slave.storage.transactions import SlavedTransactionStore
from synapse.replication.tcp.client import ReplicationClientHandler
from synapse.rest.key.v2 import KeyApiV2Resource
from synapse.server import HomeServer
from synapse.storage.engines import create_engine
from synapse.util.httpresourcetree import create_resource_tree
Expand Down Expand Up @@ -99,6 +100,9 @@ def _listen_http(self, listener_config):
),
})

if name in ["keys", "federation"]:
resources[SERVER_KEY_V2_PREFIX] = KeyApiV2Resource(self)

root_resource = create_resource_tree(resources, NoResource())

_base.listen_tcp(
Expand Down
6 changes: 6 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def default_config(name):
config.saml2_enabled = False
config.public_baseurl = None
config.default_identity_server = None
config.key_refresh_interval = 24 * 60 * 60 * 1000
config.old_signing_keys = {}
config.tls_fingerprints = []

config.use_frozen_dicts = False

Expand Down Expand Up @@ -457,6 +460,9 @@ def sign(self, message):
def verify(self, message, sig):
assert sig == b"\x9a\x87$"

def encode(self):
return b"<fake_encoded_key>"


class MockClock(object):
now = 1000
Expand Down

0 comments on commit 46b0151

Please sign in to comment.