diff options
author | John Estabrook <jestabro@vyos.io> | 2022-05-15 13:28:06 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2022-07-24 08:44:58 -0500 |
commit | 8e6f4ee3a95fbb6d4c5ae9b0a698c5fa3ea73cf4 (patch) | |
tree | 88f6901060641d80c4192b3a110a4549dd7d6605 /src/services/api/graphql/key_auth.py | |
parent | e1e9f690d3eb4cd03aba118558fffd5b6b2920c8 (diff) | |
download | vyos-1x-8e6f4ee3a95fbb6d4c5ae9b0a698c5fa3ea73cf4.tar.gz vyos-1x-8e6f4ee3a95fbb6d4c5ae9b0a698c5fa3ea73cf4.zip |
graphql: T3993: use existing key auth from REST framework
Diffstat (limited to 'src/services/api/graphql/key_auth.py')
-rw-r--r-- | src/services/api/graphql/key_auth.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/services/api/graphql/key_auth.py b/src/services/api/graphql/key_auth.py new file mode 100644 index 000000000..f756ed6d8 --- /dev/null +++ b/src/services/api/graphql/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 |