summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/key_auth.py
blob: f756ed6d8420bd3eb4da4110aed20317005d44a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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