summary refs log tree commit diff
path: root/synapse/config
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/config
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/config')
-rw-r--r--synapse/config/jwt.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/synapse/config/jwt.py b/synapse/config/jwt.py
index 5c8199612b..47f145c589 100644
--- a/synapse/config/jwt.py
+++ b/synapse/config/jwt.py
@@ -13,7 +13,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from ._base import Config
+from ._base import Config, ConfigError
+
+
+MISSING_JWT = (
+    """Missing jwt library. This is required for jwt login.
+
+    Install by running:
+        pip install pyjwt
+    """
+)
 
 
 class JWTConfig(Config):
@@ -23,6 +32,12 @@ class JWTConfig(Config):
             self.jwt_enabled = jwt_config.get("enabled", False)
             self.jwt_secret = jwt_config["secret"]
             self.jwt_algorithm = jwt_config["algorithm"]
+
+            try:
+                import jwt
+                jwt  # To stop unused lint.
+            except ImportError:
+                raise ConfigError(MISSING_JWT)
         else:
             self.jwt_enabled = False
             self.jwt_secret = None