[acls] added "fields" value for acl table
This commit is contained in:
parent
87cc59849a
commit
c97fa3b4c2
|
@ -85,19 +85,21 @@ def update_db(domain):
|
||||||
Inserts ACL into database
|
Inserts ACL into database
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
- acls (List[Callable]): List of the Route's ACL's
|
- acls [(Callable, [str])]: List of the Route's ACL's
|
||||||
- route (dict): The Route
|
- route (dict): The Route
|
||||||
"""
|
"""
|
||||||
route.pop('fct_name')
|
route.pop('fct_name')
|
||||||
acl = Acl(**route)
|
acl = Acl(**route)
|
||||||
|
|
||||||
for fct in acls:
|
for fct, keys in acls:
|
||||||
acl.acl_fct_name = fct.__name__
|
acl.acl_fct_name = fct.__name__
|
||||||
|
|
||||||
if len(acl) == 0:
|
if len(acl) != 0:
|
||||||
if fct is not None:
|
raise Exception(
|
||||||
add_acl_fct(fct)
|
'An ACL row for this route with this function already exists. Check your routers')
|
||||||
|
else:
|
||||||
|
acl.keys = keys
|
||||||
|
add_acl_fct(fct)
|
||||||
acl.insert()
|
acl.insert()
|
||||||
|
|
||||||
elif fct is None:
|
elif fct is None:
|
||||||
|
@ -223,6 +225,7 @@ def update_db(domain):
|
||||||
click.echo(f'The domain {domain} has no *{router_name}* router', err=True)
|
click.echo(f'The domain {domain} has no *{router_name}* router', err=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
add_router(router_name)
|
add_router(router_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -48,6 +48,7 @@ create table api.acl (
|
||||||
router text,
|
router text,
|
||||||
domain text,
|
domain text,
|
||||||
acl_fct_name text,
|
acl_fct_name text,
|
||||||
|
keys text[],
|
||||||
primary key (http_verb, path, router, domain, acl_fct_name)
|
primary key (http_verb, path, router, domain, acl_fct_name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue