mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 20:04:51 -04:00
Make pyjwt dependency optional
This commit is contained in:
parent
c3f8dbf6b5
commit
52ecbc2843
3 changed files with 23 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue