From 142ea24630831cb335d6002ab971bbb442bd80b4 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Fri, 18 Sep 2020 15:31:36 +0200 Subject: [PATCH] =?UTF-8?q?[routing]=C2=A0add=20the=20ACL=20name=20that=20?= =?UTF-8?q?returned=20True?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- halfapi/lib/routes.py | 15 ++++++++++++++- halfapi/models/api.sql | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/halfapi/lib/routes.py b/halfapi/lib/routes.py index e53bdf4..3ccd827 100644 --- a/halfapi/lib/routes.py +++ b/halfapi/lib/routes.py @@ -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) diff --git a/halfapi/models/api.sql b/halfapi/models/api.sql index 38863e9..169749e 100644 --- a/halfapi/models/api.sql +++ b/halfapi/models/api.sql @@ -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,