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

Commit

Permalink
Add HomeServer.signing_key property (#7805)
Browse files Browse the repository at this point in the history
... instead of duplicating `config.signing_key[0]` everywhere
  • Loading branch information
richvdh authored Jul 8, 2020
1 parent ef5ed52 commit 67593b1
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions changelog.d/7805.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `signing_key` property to `HomeServer` to save code duplication.
2 changes: 1 addition & 1 deletion synapse/events/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class EventBuilderFactory(object):
def __init__(self, hs):
self.clock = hs.get_clock()
self.hostname = hs.hostname
self.signing_key = hs.config.signing_key[0]
self.signing_key = hs.signing_key

self.store = hs.get_datastore()
self.state = hs.get_state_handler()
Expand Down
2 changes: 1 addition & 1 deletion synapse/federation/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, hs):
self.transport_layer = hs.get_federation_transport_client()

self.hostname = hs.hostname
self.signing_key = hs.config.signing_key[0]
self.signing_key = hs.signing_key

self._get_pdu_cache = ExpiringCache(
cache_name="get_pdu_cache",
Expand Down
2 changes: 1 addition & 1 deletion synapse/groups/attestations.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, hs):
self.keyring = hs.get_keyring()
self.clock = hs.get_clock()
self.server_name = hs.hostname
self.signing_key = hs.config.signing_key[0]
self.signing_key = hs.signing_key

@defer.inlineCallbacks
def verify_attestation(self, attestation, group_id, user_id, server_name=None):
Expand Down
2 changes: 1 addition & 1 deletion synapse/groups/groups_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, hs):
self.clock = hs.get_clock()
self.keyring = hs.get_keyring()
self.is_mine_id = hs.is_mine_id
self.signing_key = hs.config.signing_key[0]
self.signing_key = hs.signing_key
self.server_name = hs.hostname
self.attestations = hs.get_groups_attestation_signing()
self.transport_client = hs.get_federation_transport_client()
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ async def on_invite_request(
room_version,
event.get_pdu_json(),
self.hs.hostname,
self.hs.config.signing_key[0],
self.hs.signing_key,
)
)

Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/groups_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, hs):
self.clock = hs.get_clock()
self.keyring = hs.get_keyring()
self.is_mine_id = hs.is_mine_id
self.signing_key = hs.config.signing_key[0]
self.signing_key = hs.signing_key
self.server_name = hs.hostname
self.notifier = hs.get_notifier()
self.attestations = hs.get_groups_attestation_signing()
Expand Down
2 changes: 1 addition & 1 deletion synapse/http/matrixfederationclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class MatrixFederationHttpClient(object):

def __init__(self, hs, tls_client_options_factory):
self.hs = hs
self.signing_key = hs.config.signing_key[0]
self.signing_key = hs.signing_key
self.server_name = hs.hostname

real_reactor = hs.get_reactor()
Expand Down
2 changes: 2 additions & 0 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def __init__(self, hostname: str, config: HomeServerConfig, reactor=None, **kwar

self._reactor = reactor
self.hostname = hostname
# the key we use to sign events and requests
self.signing_key = config.key.signing_key[0]
self.config = config
self._building = {}
self._listening_services = []
Expand Down
7 changes: 2 additions & 5 deletions tests/storage/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from synapse.storage.engines import create_engine

from tests import unittest
from tests.utils import TestHomeServer
from tests.utils import TestHomeServer, default_config


class SQLBaseStoreTestCase(unittest.TestCase):
Expand All @@ -49,10 +49,7 @@ def runWithConnection(func, *args, **kwargs):

self.db_pool.runWithConnection = runWithConnection

config = Mock()
config._disable_native_upserts = True
config.caches = Mock()
config.caches.event_cache_size = 1
config = default_config(name="test", parse=True)
hs = TestHomeServer("test", config=config)

sqlite_config = {"name": "sqlite3"}
Expand Down

0 comments on commit 67593b1

Please sign in to comment.