From 83f7d64f55066af8ff7d0daf94fcdcba545a494e Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 1 May 2023 12:37:15 -0400 Subject: [PATCH 1/4] Add logging statements for incoming requests with a key ID. --- synapse/rest/key/v2/local_key_resource.py | 8 ++++++++ synapse/rest/key/v2/remote_key_resource.py | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/synapse/rest/key/v2/local_key_resource.py b/synapse/rest/key/v2/local_key_resource.py index d03e728d4208..c95338d2ff6e 100644 --- a/synapse/rest/key/v2/local_key_resource.py +++ b/synapse/rest/key/v2/local_key_resource.py @@ -34,6 +34,8 @@ class LocalKey(RestServlet): """HTTP resource containing encoding the TLS X.509 certificate and NACL signature verification keys for this server:: + GET /_matrix/key/v2/server HTTP/1.1 + GET /_matrix/key/v2/server/a.key.id HTTP/1.1 HTTP/1.1 200 OK @@ -100,6 +102,12 @@ def response_json_object(self) -> JsonDict: def on_GET( self, request: Request, key_id: Optional[str] = None ) -> Tuple[int, JsonDict]: + # Matrix 1.6 drops support for passing the key_id, this is incompatible + # with earlier versions and is allowed in order to support both. + # A warning is issued to help determine when it is safe to drop this. + if key_id: + logger.warning("Request received for local key with key ID: %s", key_id) + time_now = self.clock.time_msec() # Update the expiry time if less than half the interval remains. if time_now + self.config.key.key_refresh_interval / 2 > self.valid_until_ts: diff --git a/synapse/rest/key/v2/remote_key_resource.py b/synapse/rest/key/v2/remote_key_resource.py index ff0454ca5706..b190eb6abd0a 100644 --- a/synapse/rest/key/v2/remote_key_resource.py +++ b/synapse/rest/key/v2/remote_key_resource.py @@ -126,6 +126,15 @@ async def on_GET( self, request: Request, server: str, key_id: Optional[str] = None ) -> Tuple[int, JsonDict]: if server and key_id: + # Matrix 1.6 drops support for passing the key_id, this is incompatible + # with earlier versions and is allowed in order to support both. + # A warning is issued to help determine when it is safe to drop this. + logger.warning( + "Request received for remote key for server: %s with key ID: %s", + server, + key_id, + ) + minimum_valid_until_ts = parse_integer(request, "minimum_valid_until_ts") arguments = {} if minimum_valid_until_ts is not None: @@ -161,7 +170,7 @@ async def query_keys( time_now_ms = self.clock.time_msec() - # Map server_name->key_id->int. Note that the value of the init is unused. + # Map server_name->key_id->int. Note that the value of the int is unused. # XXX: why don't we just use a set? cache_misses: Dict[str, Dict[str, int]] = {} for (server_name, key_id, _), key_results in cached.items(): From 2ad3adebe6768fa9d169edf08bdfde9afad65018 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 9 May 2023 15:22:07 -0400 Subject: [PATCH 2/4] Declare support for 1.6. --- synapse/rest/client/versions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 5c98916ec2bc..afa531e09272 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -79,6 +79,7 @@ def on_GET(self, request: Request) -> Tuple[int, JsonDict]: "v1.3", "v1.4", "v1.5", + "v1.6", ], # as per MSC1497: "unstable_features": { From ac93cb8ba3c7526bc1048eebdb532d2d02c85093 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 9 May 2023 15:24:39 -0400 Subject: [PATCH 3/4] Newsfragment --- changelog.d/15559.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15559.feature diff --git a/changelog.d/15559.feature b/changelog.d/15559.feature new file mode 100644 index 000000000000..07f729e38c38 --- /dev/null +++ b/changelog.d/15559.feature @@ -0,0 +1 @@ +Advertise support for Matrix 1.6 on `/_matrix/client/versions`. From d94d2c4263d85e0b8ced1b4aafc0aee6ef26f704 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 10 May 2023 12:58:10 -0400 Subject: [PATCH 4/4] More logging info. --- synapse/rest/key/v2/local_key_resource.py | 5 ++++- synapse/rest/key/v2/remote_key_resource.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/synapse/rest/key/v2/local_key_resource.py b/synapse/rest/key/v2/local_key_resource.py index c95338d2ff6e..22e7bf9d8625 100644 --- a/synapse/rest/key/v2/local_key_resource.py +++ b/synapse/rest/key/v2/local_key_resource.py @@ -106,7 +106,10 @@ def on_GET( # with earlier versions and is allowed in order to support both. # A warning is issued to help determine when it is safe to drop this. if key_id: - logger.warning("Request received for local key with key ID: %s", key_id) + logger.warning( + "Request for local server key with deprecated key ID (logging to determine usage level for future removal): %s", + key_id, + ) time_now = self.clock.time_msec() # Update the expiry time if less than half the interval remains. diff --git a/synapse/rest/key/v2/remote_key_resource.py b/synapse/rest/key/v2/remote_key_resource.py index b190eb6abd0a..8f3865d41233 100644 --- a/synapse/rest/key/v2/remote_key_resource.py +++ b/synapse/rest/key/v2/remote_key_resource.py @@ -130,7 +130,7 @@ async def on_GET( # with earlier versions and is allowed in order to support both. # A warning is issued to help determine when it is safe to drop this. logger.warning( - "Request received for remote key for server: %s with key ID: %s", + "Request for remote server key with deprecated key ID (logging to determine usage level for future removal): %s / %s", server, key_id, )