summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/libs/key_auth.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2022-10-23 11:06:03 -0500
committerJohn Estabrook <jestabro@vyos.io>2022-10-25 09:03:06 -0500
commit7038b761302be2ec90338981830b8cd7cf887381 (patch)
tree1eb7c93dba0694b8c6dbce1ec522a2a61b06a439 /src/services/api/graphql/libs/key_auth.py
parent093ac258c11894b07afd9e85a61778d23e356718 (diff)
downloadvyos-1x-7038b761302be2ec90338981830b8cd7cf887381.tar.gz
vyos-1x-7038b761302be2ec90338981830b8cd7cf887381.zip
graphql: T4574: reorganize directory structure for clarity
Diffstat (limited to 'src/services/api/graphql/libs/key_auth.py')
-rw-r--r--src/services/api/graphql/libs/key_auth.py18
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