summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/libs/token_auth.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-09-30 20:40:02 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-09-30 21:56:06 -0500
commit7e23fd9da028b3c623b69fda8a6bcfd887f1c18c (patch)
treeb3b4e32a845f7635a1107feaa6a287eb9121818f /src/services/api/graphql/libs/token_auth.py
parent40d966310cb5d8d758f7fa801facd0a560795783 (diff)
downloadvyos-1x-7e23fd9da028b3c623b69fda8a6bcfd887f1c18c.tar.gz
vyos-1x-7e23fd9da028b3c623b69fda8a6bcfd887f1c18c.zip
http-api: T6736: normalize formatting
Diffstat (limited to 'src/services/api/graphql/libs/token_auth.py')
-rw-r--r--src/services/api/graphql/libs/token_auth.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/services/api/graphql/libs/token_auth.py b/src/services/api/graphql/libs/token_auth.py
index 2d772e035..4f743a096 100644
--- a/src/services/api/graphql/libs/token_auth.py
+++ b/src/services/api/graphql/libs/token_auth.py
@@ -19,7 +19,7 @@ import uuid
import pam
from secrets import token_hex
-from ... session import SessionState
+from ...session import SessionState
def _check_passwd_pam(username: str, passwd: str) -> bool:
@@ -48,13 +48,13 @@ def generate_token(user: str, passwd: str, secret: str, exp: int) -> dict:
payload_data = {'iss': user, 'sub': user_id, 'exp': exp}
secret = getattr(state, 'secret', None)
if secret is None:
- return {"errors": ['missing secret']}
- token = jwt.encode(payload=payload_data, key=secret, algorithm="HS256")
+ return {'errors': ['missing secret']}
+ token = jwt.encode(payload=payload_data, key=secret, algorithm='HS256')
users |= {user_id: user}
return {'token': token}
else:
- return {"errors": ['failed pam authentication']}
+ return {'errors': ['failed pam authentication']}
def get_user_context(request):
@@ -70,7 +70,7 @@ def get_user_context(request):
try:
secret = getattr(state, 'secret', None)
- payload = jwt.decode(token, secret, algorithms=["HS256"])
+ payload = jwt.decode(token, secret, algorithms=['HS256'])
user_id: str = payload.get('sub')
if user_id is None:
return context