[release] 0.6.10

- Add "x-out" field in HTTP headers when "out" parameters are specified for a
  route
- Add "out" kwarg for not-async functions that specify it

- Hide data fields in args_check logs

- Fix testing lib for domains (add default secret and debug option)

- Domains now need to include the following variables in their __init__.py
    - __name__ (str, optional)
    - __id__ (str, optional)
- halfapi domain

- Mounts domain routers with their ACLs as decorator
- Configuration example files for systemd and a system-wide halfapi install
- Runs projects
- Handles JWT authentication middleware
This commit is contained in:
Maxime Alves LIRMM 2022-03-08 19:24:21 +01:00
parent 84179743a6
commit f7879c6388
6 changed files with 21 additions and 1 deletions

View File

@ -1,5 +1,11 @@
# HalfAPI # HalfAPI
## 0.6.10
- Add "x-out" field in HTTP headers when "out" parameters are specified for a
route
- Add "out" kwarg for not-async functions that specify it
## 0.6.9 ## 0.6.9
- Hide data fields in args_check logs - Hide data fields in args_check logs

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
__version__ = '0.6.9' __version__ = '0.6.10'
def version(): def version():
return f'HalfAPI version:{__version__}' return f'HalfAPI version:{__version__}'

View File

@ -85,6 +85,8 @@ class HalfRoute(Route):
'Args for current route (%s)', param.get('args')) 'Args for current route (%s)', param.get('args'))
if 'out' in param:
req.scope['out'] = param['out'].copy()
if 'check' in req.query_params: if 'check' in req.query_params:
return PlainTextResponse(param['acl'].__name__) return PlainTextResponse(param['acl'].__name__)

View File

@ -94,6 +94,9 @@ def args_check(fct):
kwargs['data'] = data kwargs['data'] = data
if req.scope.get('out'):
kwargs['out'] = req.scope.get('out').copy()
return await fct(req, *args, **kwargs) return await fct(req, *args, **kwargs)
return caller return caller

View File

@ -64,6 +64,10 @@ def route_decorator(fct: FunctionType, ret_type: str = 'json') -> Coroutine:
if 'data' in fct_args_spec: if 'data' in fct_args_spec:
fct_args['data'] = kwargs.get('data') fct_args['data'] = kwargs.get('data')
if 'out' in fct_args_spec:
fct_args['out'] = kwargs.get('out')
""" If format argument is specified (either by get or by post param) """ If format argument is specified (either by get or by post param)
""" """
ret_type = fct_args.get('data', {}).get('format', 'json') ret_type = fct_args.get('data', {}).get('format', 'json')

View File

@ -56,6 +56,11 @@ class DomainMiddleware(BaseHTTPMiddleware):
response.headers['x-args-optional'] = \ response.headers['x-args-optional'] = \
','.join(request.scope['args']['optional']) ','.join(request.scope['args']['optional'])
if len(request.scope.get('out', set())):
response.headers['x-out'] = \
','.join(request.scope['out'])
response.headers['x-domain'] = self.domain['name'] response.headers['x-domain'] = self.domain['name']
return response return response