Use shared access for synthetic breast follow-up
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""Run the cohort endpoints locally against an explicitly supplied synthetic SQLite file."""
|
||||
|
||||
import hmac
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sqlite3
|
||||
@@ -24,9 +23,6 @@ if os.name == 'nt':
|
||||
|
||||
|
||||
path = Path(os.environ['CAMA_SYNTHETIC_SQLITE']).resolve(strict=True)
|
||||
token = os.environ['CAMA_COHORT_ACCESS_TOKEN']
|
||||
if len(token) < 32:
|
||||
raise ValueError('The access token must be at least 32 characters')
|
||||
if not path.is_file():
|
||||
raise ValueError('The synthetic SQLite database must already exist')
|
||||
|
||||
@@ -49,11 +45,7 @@ def read(cutoff):
|
||||
return CamaCohort(session).rows(cutoff)
|
||||
|
||||
|
||||
def authorized(request):
|
||||
return hmac.compare_digest(request.headers.get('X-Cama-Cohort-Token', ''), token)
|
||||
|
||||
|
||||
app.config.update(CAMA_COHORT_READER=read, CAMA_COHORT_ACCESS=authorized)
|
||||
app.config['CAMA_COHORT_READER'] = read
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='127.0.0.1', port=int(os.environ.get('CAMA_COHORT_PORT', '5059')), debug=False)
|
||||
|
||||
Reference in New Issue
Block a user