DSN -> SECRET dans middleware

This commit is contained in:
Maxime Alves LIRMM 2020-07-03 11:32:18 +02:00 committed by Maxime Alves LIRMM@home
parent 0a755dc76f
commit 70ee654ed9
1 changed files with 3 additions and 2 deletions

View File

@ -223,13 +223,14 @@ async def root(request):
def check_conf(): def check_conf():
if not environ.get('HALFORM_SECRET', False): if not environ.get('HALFORM_SECRET', False):
print('Missing HALFORM_SECRET variable from configuration') environ['HALFORM_SECRET'] = 'secret'
print('Missing HALFORM_SECRET variable from configuration, seting to default')
if not environ.get('HALFORM_DSN', False): if not environ.get('HALFORM_DSN', False):
print('Missing HALFORM_DSN variable from configuration') print('Missing HALFORM_DSN variable from configuration')
app = Starlette( app = Starlette(
middleware=[ middleware=[
Middleware(AuthenticationMiddleware, backend=JWTAuthenticationBackend(secret_key=environ.get('HALFORM_DSN'))), Middleware(AuthenticationMiddleware, backend=JWTAuthenticationBackend(secret_key=environ.get('HALFORM_SECRET'))),
Middleware(AclCallerMiddleware), Middleware(AclCallerMiddleware),
], ],
on_startup=[startup], on_startup=[startup],