[routing] add the ACL name that returned True

This commit is contained in:
Maxime Alves LIRMM 2020-09-18 15:31:36 +02:00
parent bcc4a3e9d8
commit 142ea24630
2 changed files with 15 additions and 2 deletions

View File

@ -40,7 +40,20 @@ def get_routes(domains=None):
for acl_fct_name, keys in acls:
acl_fct = getattr(acls_mod, acl_fct_name)
if acl_fct(req, *args, **kwargs):
return await fct(req, *args, **{ **kwargs, **{'keys': keys} })
"""
We the 'acl' and 'keys' kwargs values to let the
decorated function know which ACL function answered
True, and which keys the request will return
"""
return await fct(
req, *args,
**{
**kwargs,
**{
'acl': f'{acls_mod.__name__}.{acl_fct_name}',
'keys': keys
}
})
raise HTTPException(401)

View File

@ -1,6 +1,6 @@
create schema api;
create type verb as enum ('POST', 'GET', 'PUT', 'DELETE');
create type verb as enum ('POST', 'GET', 'PUT', 'PATCH', 'DELETE');
create table api.domain (
name text,