From fa72fb587017e269449647074bd6e4174136e97a Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 11 Jun 2020 14:48:52 +0200 Subject: [PATCH 1/8] rename m.login.jwt to org.matrix.login.jwt --- synapse/rest/client/v1/login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py index dceb2792fa7a..d7cfafbf8808 100644 --- a/synapse/rest/client/v1/login.py +++ b/synapse/rest/client/v1/login.py @@ -73,7 +73,7 @@ class LoginRestServlet(RestServlet): CAS_TYPE = "m.login.cas" SSO_TYPE = "m.login.sso" TOKEN_TYPE = "m.login.token" - JWT_TYPE = "m.login.jwt" + JWT_TYPE = "org.matrix.login.jwt" def __init__(self, hs): super(LoginRestServlet, self).__init__() From 2675992f860273003b96900d5b28d7cac6f5a813 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 11 Jun 2020 14:53:57 +0200 Subject: [PATCH 2/8] adapt tests --- tests/rest/client/v1/test_login.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/rest/client/v1/test_login.py b/tests/rest/client/v1/test_login.py index 9033f09fd2e3..21fc489cb3c5 100644 --- a/tests/rest/client/v1/test_login.py +++ b/tests/rest/client/v1/test_login.py @@ -526,7 +526,7 @@ def jwt_encode(self, token, secret=jwt_secret): return jwt.encode(token, secret, "HS256").decode("ascii") def jwt_login(self, *args): - params = json.dumps({"type": "m.login.jwt", "token": self.jwt_encode(*args)}) + params = json.dumps({"type": "org.matrix.login.jwt", "token": self.jwt_encode(*args)}) request, channel = self.make_request(b"POST", LOGIN_URL, params) self.render(request) return channel @@ -568,7 +568,7 @@ def test_login_no_sub(self): self.assertEqual(channel.json_body["error"], "Invalid JWT") def test_login_no_token(self): - params = json.dumps({"type": "m.login.jwt"}) + params = json.dumps({"type": "org.matrix.login.jwt"}) request, channel = self.make_request(b"POST", LOGIN_URL, params) self.render(request) self.assertEqual(channel.result["code"], b"401", channel.result) @@ -640,7 +640,7 @@ def jwt_encode(self, token, secret=jwt_privatekey): return jwt.encode(token, secret, "RS256").decode("ascii") def jwt_login(self, *args): - params = json.dumps({"type": "m.login.jwt", "token": self.jwt_encode(*args)}) + params = json.dumps({"type": "org.matrix.login.jwt", "token": self.jwt_encode(*args)}) request, channel = self.make_request(b"POST", LOGIN_URL, params) self.render(request) return channel From 24b9a46774513dbd46d652cf9d3f08222aa4541a Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 11 Jun 2020 14:54:39 +0200 Subject: [PATCH 3/8] add changelog --- changelog.d/7675.type | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7675.type diff --git a/changelog.d/7675.type b/changelog.d/7675.type new file mode 100644 index 000000000000..99402cd39ca3 --- /dev/null +++ b/changelog.d/7675.type @@ -0,0 +1 @@ +Rename m.login.jwt to org.matrix.login.jwt as that is not in the spec. From 2216714e052a0becc49ae2ca863c855a85ab7fbb Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 11 Jun 2020 14:57:53 +0200 Subject: [PATCH 4/8] code format --- tests/rest/client/v1/test_login.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/rest/client/v1/test_login.py b/tests/rest/client/v1/test_login.py index 21fc489cb3c5..fd9799995654 100644 --- a/tests/rest/client/v1/test_login.py +++ b/tests/rest/client/v1/test_login.py @@ -526,7 +526,9 @@ def jwt_encode(self, token, secret=jwt_secret): return jwt.encode(token, secret, "HS256").decode("ascii") def jwt_login(self, *args): - params = json.dumps({"type": "org.matrix.login.jwt", "token": self.jwt_encode(*args)}) + params = json.dumps( + {"type": "org.matrix.login.jwt", "token": self.jwt_encode(*args)} + ) request, channel = self.make_request(b"POST", LOGIN_URL, params) self.render(request) return channel @@ -640,7 +642,9 @@ def jwt_encode(self, token, secret=jwt_privatekey): return jwt.encode(token, secret, "RS256").decode("ascii") def jwt_login(self, *args): - params = json.dumps({"type": "org.matrix.login.jwt", "token": self.jwt_encode(*args)}) + params = json.dumps( + {"type": "org.matrix.login.jwt", "token": self.jwt_encode(*args)} + ) request, channel = self.make_request(b"POST", LOGIN_URL, params) self.render(request) return channel From 028f2c9246b2f22898cb6ffab1f56bb039f9000c Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 11 Jun 2020 15:00:29 +0200 Subject: [PATCH 5/8] rename changelog file --- changelog.d/{7675.type => 7675.misc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{7675.type => 7675.misc} (100%) diff --git a/changelog.d/7675.type b/changelog.d/7675.misc similarity index 100% rename from changelog.d/7675.type rename to changelog.d/7675.misc From fc27cf027aa88405a4933300998e8b3fb1547297 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 18 Jun 2020 17:18:19 +0200 Subject: [PATCH 6/8] add deprecated type --- synapse/rest/client/v1/login.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py index d7cfafbf8808..fdc11ced2012 100644 --- a/synapse/rest/client/v1/login.py +++ b/synapse/rest/client/v1/login.py @@ -74,6 +74,7 @@ class LoginRestServlet(RestServlet): SSO_TYPE = "m.login.sso" TOKEN_TYPE = "m.login.token" JWT_TYPE = "org.matrix.login.jwt" + JWT_TYPE_DEPRECATED = "m.login.jwt" def __init__(self, hs): super(LoginRestServlet, self).__init__() @@ -108,6 +109,7 @@ def on_GET(self, request): flows = [] if self.jwt_enabled: flows.append({"type": LoginRestServlet.JWT_TYPE}) + flows.append({"type": LoginRestServlet.JWT_TYPE_DEPRECATED}) if self.cas_enabled: # we advertise CAS for backwards compat, though MSC1721 renamed it @@ -141,6 +143,7 @@ async def on_POST(self, request): try: if self.jwt_enabled and ( login_submission["type"] == LoginRestServlet.JWT_TYPE + or login_submission["type"] == LoginRestServlet.JWT_TYPE_DEPRECATED ): result = await self.do_jwt_login(login_submission) elif login_submission["type"] == LoginRestServlet.TOKEN_TYPE: From 420addf6ef83f4acb2acfbb8bf53de5296f0a8f7 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 18 Jun 2020 17:33:39 +0200 Subject: [PATCH 7/8] update changelog --- changelog.d/7675.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/7675.misc b/changelog.d/7675.misc index 99402cd39ca3..531c7f573a81 100644 --- a/changelog.d/7675.misc +++ b/changelog.d/7675.misc @@ -1 +1 @@ -Rename m.login.jwt to org.matrix.login.jwt as that is not in the spec. +Deprecate m.login.jwt in favour of org.matrix.login.jwt as m.login.jwt is not in the spec. From c42337568fba11fa658ecd0db3450de05ca24d89 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 18 Jun 2020 16:38:13 +0100 Subject: [PATCH 8/8] Update and rename 7675.misc to 7675.removal --- changelog.d/7675.misc | 1 - changelog.d/7675.removal | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 changelog.d/7675.misc create mode 100644 changelog.d/7675.removal diff --git a/changelog.d/7675.misc b/changelog.d/7675.misc deleted file mode 100644 index 531c7f573a81..000000000000 --- a/changelog.d/7675.misc +++ /dev/null @@ -1 +0,0 @@ -Deprecate m.login.jwt in favour of org.matrix.login.jwt as m.login.jwt is not in the spec. diff --git a/changelog.d/7675.removal b/changelog.d/7675.removal new file mode 100644 index 000000000000..2500e2c578e7 --- /dev/null +++ b/changelog.d/7675.removal @@ -0,0 +1 @@ +Deprecate `m.login.jwt` login method in favour of `org.matrix.login.jwt`, as `m.login.jwt` is not part of the Matrix spec.