mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Add HomeServer.signing_key
property (#7805)
... instead of duplicating `config.signing_key[0]` everywhere
This commit is contained in:
parent
ef5ed5292b
commit
67593b1728
1
changelog.d/7805.misc
Normal file
1
changelog.d/7805.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Add `signing_key` property to `HomeServer` to save code duplication.
|
@ -162,7 +162,7 @@ class EventBuilderFactory(object):
|
|||||||
def __init__(self, hs):
|
def __init__(self, hs):
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.hostname = hs.hostname
|
self.hostname = hs.hostname
|
||||||
self.signing_key = hs.config.signing_key[0]
|
self.signing_key = hs.signing_key
|
||||||
|
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.state = hs.get_state_handler()
|
self.state = hs.get_state_handler()
|
||||||
|
@ -87,7 +87,7 @@ class FederationClient(FederationBase):
|
|||||||
self.transport_layer = hs.get_federation_transport_client()
|
self.transport_layer = hs.get_federation_transport_client()
|
||||||
|
|
||||||
self.hostname = hs.hostname
|
self.hostname = hs.hostname
|
||||||
self.signing_key = hs.config.signing_key[0]
|
self.signing_key = hs.signing_key
|
||||||
|
|
||||||
self._get_pdu_cache = ExpiringCache(
|
self._get_pdu_cache = ExpiringCache(
|
||||||
cache_name="get_pdu_cache",
|
cache_name="get_pdu_cache",
|
||||||
|
@ -70,7 +70,7 @@ class GroupAttestationSigning(object):
|
|||||||
self.keyring = hs.get_keyring()
|
self.keyring = hs.get_keyring()
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
self.signing_key = hs.config.signing_key[0]
|
self.signing_key = hs.signing_key
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def verify_attestation(self, attestation, group_id, user_id, server_name=None):
|
def verify_attestation(self, attestation, group_id, user_id, server_name=None):
|
||||||
|
@ -41,7 +41,7 @@ class GroupsServerWorkerHandler(object):
|
|||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.keyring = hs.get_keyring()
|
self.keyring = hs.get_keyring()
|
||||||
self.is_mine_id = hs.is_mine_id
|
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.server_name = hs.hostname
|
||||||
self.attestations = hs.get_groups_attestation_signing()
|
self.attestations = hs.get_groups_attestation_signing()
|
||||||
self.transport_client = hs.get_federation_transport_client()
|
self.transport_client = hs.get_federation_transport_client()
|
||||||
|
@ -1567,7 +1567,7 @@ class FederationHandler(BaseHandler):
|
|||||||
room_version,
|
room_version,
|
||||||
event.get_pdu_json(),
|
event.get_pdu_json(),
|
||||||
self.hs.hostname,
|
self.hs.hostname,
|
||||||
self.hs.config.signing_key[0],
|
self.hs.signing_key,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class GroupsLocalWorkerHandler(object):
|
|||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.keyring = hs.get_keyring()
|
self.keyring = hs.get_keyring()
|
||||||
self.is_mine_id = hs.is_mine_id
|
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.server_name = hs.hostname
|
||||||
self.notifier = hs.get_notifier()
|
self.notifier = hs.get_notifier()
|
||||||
self.attestations = hs.get_groups_attestation_signing()
|
self.attestations = hs.get_groups_attestation_signing()
|
||||||
|
@ -176,7 +176,7 @@ class MatrixFederationHttpClient(object):
|
|||||||
|
|
||||||
def __init__(self, hs, tls_client_options_factory):
|
def __init__(self, hs, tls_client_options_factory):
|
||||||
self.hs = hs
|
self.hs = hs
|
||||||
self.signing_key = hs.config.signing_key[0]
|
self.signing_key = hs.signing_key
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
|
|
||||||
real_reactor = hs.get_reactor()
|
real_reactor = hs.get_reactor()
|
||||||
|
@ -232,6 +232,8 @@ class HomeServer(object):
|
|||||||
|
|
||||||
self._reactor = reactor
|
self._reactor = reactor
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
|
# the key we use to sign events and requests
|
||||||
|
self.signing_key = config.key.signing_key[0]
|
||||||
self.config = config
|
self.config = config
|
||||||
self._building = {}
|
self._building = {}
|
||||||
self._listening_services = []
|
self._listening_services = []
|
||||||
|
@ -25,7 +25,7 @@ from synapse.storage.database import Database
|
|||||||
from synapse.storage.engines import create_engine
|
from synapse.storage.engines import create_engine
|
||||||
|
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
from tests.utils import TestHomeServer
|
from tests.utils import TestHomeServer, default_config
|
||||||
|
|
||||||
|
|
||||||
class SQLBaseStoreTestCase(unittest.TestCase):
|
class SQLBaseStoreTestCase(unittest.TestCase):
|
||||||
@ -49,10 +49,7 @@ class SQLBaseStoreTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
self.db_pool.runWithConnection = runWithConnection
|
self.db_pool.runWithConnection = runWithConnection
|
||||||
|
|
||||||
config = Mock()
|
config = default_config(name="test", parse=True)
|
||||||
config._disable_native_upserts = True
|
|
||||||
config.caches = Mock()
|
|
||||||
config.caches.event_cache_size = 1
|
|
||||||
hs = TestHomeServer("test", config=config)
|
hs = TestHomeServer("test", config=config)
|
||||||
|
|
||||||
sqlite_config = {"name": "sqlite3"}
|
sqlite_config = {"name": "sqlite3"}
|
||||||
|
Loading…
Reference in New Issue
Block a user