From 68f628ec5a0aa90bdc6a095d93f28df88cbecb95 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Mon, 19 Feb 2024 13:32:18 -0600 Subject: [PATCH] authentication with other databases --- healthcareio/__main__.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/healthcareio/__main__.py b/healthcareio/__main__.py index 43f513c..67a571d 100644 --- a/healthcareio/__main__.py +++ b/healthcareio/__main__.py @@ -44,7 +44,7 @@ app = typer.Typer() CONFIG_FOLDER = os.sep.join([os.environ['HOME'],'.healthcareio']) HOST = "https://healthcareio.the-phi.com" if 'PARSER_HOST_URL' not in os.environ else os.environ['PARSER_HOST_URL'] @app.command(name='init') -def config(email:str,provider:str='sqlite') : +def config(email:str,provider:str='sqlite',auth_file:str=None) : """\b Generate configuration file needed with default data store. For supported data-store providers visit https://hiplab.mc.vanderbilt.edu/git/hiplab/data-transport.git @@ -58,7 +58,14 @@ def config(email:str,provider:str='sqlite') : if not os.path.exists(CONFIG_FOLDER) : os.mkdir(CONFIG_FOLDER) - + + # + # NOTE: + # if a provider is setup as an environment variable, we override the parameter + # This is designed for developement and containers + # + if 'X12_DATABASE' in os.environ : + provider = os.environ['X12_DATABASE'] if provider in ['sqlite','sqlite3'] : _db = os.sep.join([CONFIG_FOLDER,_db+'.db3']) @@ -75,6 +82,11 @@ def config(email:str,provider:str='sqlite') : } } + if auth_file and os.path.exists(auth_file) and provider not in ['sqlite','sqlite3'] : + f = open(auth_file) + _auth = json.loads(f.read()) + f.close() + _config['store'] = dict(_config['store'],**_auth) # # Let create or retrieve a user's key/token to make sure he/she has access to features they need # This would also allow us to allow the users to be informed of new versions