diff options
author | John Estabrook <jestabro@vyos.io> | 2023-02-26 15:21:13 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-02-26 15:21:13 -0600 |
commit | 6d29c4c76b5affa64ae1b2e697984cafe5664246 (patch) | |
tree | cc1e7f8c9b572bb42271743da5e52d12ac03deff /src/services/api/graphql/libs | |
parent | 40e0cb294e0377fdfe11171b35d78bd27e231df2 (diff) | |
download | vyos-1x-6d29c4c76b5affa64ae1b2e697984cafe5664246.tar.gz vyos-1x-6d29c4c76b5affa64ae1b2e697984cafe5664246.zip |
graphql: T4979: add user info to token request
Diffstat (limited to 'src/services/api/graphql/libs')
-rw-r--r-- | src/services/api/graphql/libs/token_auth.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/services/api/graphql/libs/token_auth.py b/src/services/api/graphql/libs/token_auth.py index 2100eba7f..8585485c9 100644 --- a/src/services/api/graphql/libs/token_auth.py +++ b/src/services/api/graphql/libs/token_auth.py @@ -29,14 +29,13 @@ def generate_token(user: str, passwd: str, secret: str, exp: int) -> dict: payload_data = {'iss': user, 'sub': user_id, 'exp': exp} secret = state.settings.get('secret') if secret is None: - return { - "success": False, - "errors": ['failed secret generation'] - } + 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']} def get_user_context(request): context = {} |