diff options
author | John Estabrook <jestabro@vyos.io> | 2022-10-25 12:08:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-25 12:08:42 -0500 |
commit | 1265b15ffc8baa05177c707f30205d70528c5dc6 (patch) | |
tree | 8cb9715666250f8599147d066bd93a9a06df4962 /src/services/api/graphql/libs/key_auth.py | |
parent | ec82d60828500a56b6fe8357970bf839053ac0af (diff) | |
parent | 3db5ba8ef354d80f080cc1baacf33d77ccbb6222 (diff) | |
download | vyos-1x-1265b15ffc8baa05177c707f30205d70528c5dc6.tar.gz vyos-1x-1265b15ffc8baa05177c707f30205d70528c5dc6.zip |
Merge pull request #1613 from jestabro/graphql-hybrid-auth
graphql: T4574: add JWT token authentication
Diffstat (limited to 'src/services/api/graphql/libs/key_auth.py')
-rw-r--r-- | src/services/api/graphql/libs/key_auth.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/services/api/graphql/libs/key_auth.py b/src/services/api/graphql/libs/key_auth.py new file mode 100644 index 000000000..2db0f7d48 --- /dev/null +++ b/src/services/api/graphql/libs/key_auth.py @@ -0,0 +1,18 @@ + +from .. import state + +def check_auth(key_list, key): + if not key_list: + return None + key_id = None + for k in key_list: + if k['key'] == key: + key_id = k['id'] + return key_id + +def auth_required(key): + api_keys = None + api_keys = state.settings['app'].state.vyos_keys + key_id = check_auth(api_keys, key) + state.settings['app'].state.vyos_id = key_id + return key_id |