Added logging for acls

This commit is contained in:
Maxime Alves LIRMM@home 2020-11-04 13:32:33 +01:00
parent 73d49031a7
commit 56657036e4
1 changed files with 8 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from functools import wraps from functools import wraps
import logging
from typing import Callable, List, Dict, Generator from typing import Callable, List, Dict, Generator
from types import ModuleType, FunctionType from types import ModuleType, FunctionType
@ -9,6 +10,9 @@ from starlette.requests import Request
from halfapi.lib.domain import gen_domain_routes, VERBS from halfapi.lib.domain import gen_domain_routes, VERBS
logger = logging.getLogger('uvicorn.asgi')
class DomainNotFoundError(Exception): class DomainNotFoundError(Exception):
pass pass
@ -38,8 +42,12 @@ def route_acl_decorator(fct: Callable, params: List[Dict]):
passed = param['acl']()(req, *args, **kwargs) passed = param['acl']()(req, *args, **kwargs)
if not passed: if not passed:
logger.debug(
f'ACL FAIL for current route ({fct} - {param.get("acl")})')
continue continue
logger.debug(f'ACL OK for current route ({fct} - {param.get("acl")})')
return await fct( return await fct(
req, *args, req, *args,
**{ **{