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