Compare commits

...

4 Commits

Author SHA1 Message Date
Brendan Abolivier
25507bffc6 Merge branch 'develop' into babolivier/sign_json_module 2022-03-28 13:54:02 +01:00
Brendan Abolivier
571d3bf002 Merge branch 'develop' of github.com:matrix-org/synapse into babolivier/sign_json_module 2022-03-02 17:52:39 +00:00
Brendan Abolivier
11f7098a89 Changelog 2022-03-02 15:44:42 +00:00
Brendan Abolivier
3e897cc975 Allow modules to sign JSON using the homeserver's keys 2022-03-02 15:26:34 +00:00
2 changed files with 17 additions and 0 deletions

View File

@@ -0,0 +1 @@
Allow modules to sign JSON using the homeserver's keys.

View File

@@ -30,6 +30,7 @@ from typing import (
import attr
import jinja2
from signedjson.sign import sign_json
from twisted.internet import defer
from twisted.web.resource import Resource
@@ -1286,6 +1287,21 @@ class ModuleApi:
"""
await self._registration_handler.check_username(username)
def sign_json(self, body: JsonDict) -> JsonDict:
"""Signs a dictionary with the homeserver's key, before it's sent as JSON.
Added in Synapse v1.55.0.
Args:
body: The dictionary to sign.
Returns:
The dictionary with a signature appended to it.
See https://github.com/matrix-org/python-signedjson#format for more
information on the format used.
"""
return sign_json(body, self._server_name, self._hs.signing_key)
class PublicRoomListManager:
"""Contains methods for adding to, removing from and querying whether a room