summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/libs/key_auth.py
blob: 2db0f7d48b2a53fd198cb05952dade966cb024c0 (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