nipapd: Make it possible to start without jwt
Make it possible to use the NIPAP modules without having the JWT module
installed, similar to how it's done with LDAP.
@@ -76,7 +76,11 @@ import sqlite3
import string
import random
import requests
+
+try:
import jwt
+except ImportError:
+ jwt = None
try:
import ldap
@@ -329,6 +333,10 @@ class JwtAuth(BaseAuth):
if self._cfg.has_option(base_auth_backend, 'rw_group'):
self._jwt_rw_group = self._cfg.get(base_auth_backend, 'rw_group')
+ if not jwt:
+ self._logger.error('Unable to load Python jwt module, please verify it is installed')
+ raise AuthError('Unable to authenticate')
+
def authenticate(self):
""" Verify authentication.
