diff options
author | Daniil Baturin <daniil@vyos.io> | 2022-07-25 10:34:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 10:34:17 +0100 |
commit | 3337aedd5f7ff48bfad051d760023a188fdace70 (patch) | |
tree | 3dc5b5c22444430a74f8d0f8a8ed54415a8ccd47 /src/services/api/graphql/key_auth.py | |
parent | e1e9f690d3eb4cd03aba118558fffd5b6b2920c8 (diff) | |
parent | f9d6f089014007193996e51757f72a8bf7ec78b9 (diff) | |
download | vyos-1x-3337aedd5f7ff48bfad051d760023a188fdace70.tar.gz vyos-1x-3337aedd5f7ff48bfad051d760023a188fdace70.zip |
Merge pull request #1431 from jestabro/gql-dev
graphql: T4567: Merge experimental branch of GraphQL development
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 |