diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-05-31 11:34:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-31 11:34:09 +0100 |
commit | 2ae3cc287e915b6b84be84518f2bb21557b5f17e (patch) | |
tree | 270b851f2d4ea89843b97b3c52589ab980542eaf /synapse/crypto/keyring.py | |
parent | Merge pull request #5293 from Kagamihime/messages-federation-format (diff) | |
parent | use attr.s for VerifyKeyRequest (diff) | |
download | synapse-2ae3cc287e915b6b84be84518f2bb21557b5f17e.tar.xz |
Merge pull request #5296 from matrix-org/rav/server_keys/04-use-attrs-for_verify-request
use attr.s for VerifyKeyRequest
Diffstat (limited to 'synapse/crypto/keyring.py')
-rw-r--r-- | synapse/crypto/keyring.py | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py index c63f106cf3..e1e026214f 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -15,12 +15,12 @@ # limitations under the License. import logging -from collections import namedtuple import six from six import raise_from from six.moves import urllib +import attr from signedjson.key import ( decode_verify_key_bytes, encode_verify_key_base64, @@ -57,22 +57,26 @@ from synapse.util.retryutils import NotRetryingDestination logger = logging.getLogger(__name__) -VerifyKeyRequest = namedtuple( - "VerifyRequest", ("server_name", "key_ids", "json_object", "deferred") -) -""" -A request for a verify key to verify a JSON object. - -Attributes: - server_name(str): The name of the server to verify against. - key_ids(set(str)): The set of key_ids to that could be used to verify the - JSON object - json_object(dict): The JSON object to verify. - deferred(Deferred[str, str, nacl.signing.VerifyKey]): - A deferred (server_name, key_id, verify_key) tuple that resolves when - a verify key has been fetched. The deferreds' callbacks are run with no - logcontext. -""" +@attr.s(slots=True, cmp=False) +class VerifyKeyRequest(object): + """ + A request for a verify key to verify a JSON object. + + Attributes: + server_name(str): The name of the server to verify against. + key_ids(set[str]): The set of key_ids to that could be used to verify the + JSON object + json_object(dict): The JSON object to verify. + deferred(Deferred[str, str, nacl.signing.VerifyKey]): + A deferred (server_name, key_id, verify_key) tuple that resolves when + a verify key has been fetched. The deferreds' callbacks are run with no + logcontext. + """ + + server_name = attr.ib() + key_ids = attr.ib() + json_object = attr.ib() + deferred = attr.ib() class KeyLookupError(ValueError): |