summary refs log tree commit diff
path: root/synapse/rest/client/v1/login.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-04-25 14:30:15 +0100
committerErik Johnston <erik@matrix.org>2016-04-25 14:30:15 +0100
commit52ecbc2843de51b3685529e63cd3815e826b6d90 (patch)
tree1dd2750fe6ac6534dded42e8bc294c0a4363bd37 /synapse/rest/client/v1/login.py
parentMerge pull request #748 from matrix-org/markjh/split_out_site.py (diff)
downloadsynapse-52ecbc2843de51b3685529e63cd3815e826b6d90.tar.xz
Make pyjwt dependency optional
Diffstat (limited to 'synapse/rest/client/v1/login.py')
-rw-r--r--synapse/rest/client/v1/login.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py
index 166a78026a..3b5544851b 100644
--- a/synapse/rest/client/v1/login.py
+++ b/synapse/rest/client/v1/login.py
@@ -33,9 +33,6 @@ from saml2.client import Saml2Client
 
 import xml.etree.ElementTree as ET
 
-import jwt
-from jwt.exceptions import InvalidTokenError
-
 
 logger = logging.getLogger(__name__)
 
@@ -226,8 +223,13 @@ class LoginRestServlet(ClientV1RestServlet):
     def do_jwt_login(self, login_submission):
         token = login_submission.get("token", None)
         if token is None:
-            raise LoginError(401, "Token field for JWT is missing",
-                             errcode=Codes.UNAUTHORIZED)
+            raise LoginError(
+                401, "Token field for JWT is missing",
+                errcode=Codes.UNAUTHORIZED
+            )
+
+        import jwt
+        from jwt.exceptions import InvalidTokenError
 
         try:
             payload = jwt.decode(token, self.jwt_secret, algorithms=[self.jwt_algorithm])