Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
removed secret name out of code
Browse files Browse the repository at this point in the history
  • Loading branch information
sayaHub committed Nov 23, 2018
1 parent 1768344 commit 1ea740a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ click==6.7
Babel==2.6.0
Flask-Caching==1.4.0
pymongo==3.7.0
azure-keyvault==1.1.0
msrestazure==0.5.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'click==6.7',
'Babel==2.6.0',
'Flask-Caching==1.4.0',
'azure-keyvault=1.1.0',
'azure-keyvault==1.1.0',
'msrestazure==0.5.1'
],
extras_require={
Expand Down
13 changes: 6 additions & 7 deletions track/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from azure.keyvault import KeyVaultClient
from msrestazure.azure_active_directory import MSIAuthentication, ServicePrincipalCredentials

class Config:

class Config:
DEBUG = False
TESTING = False
MONGO_URI = "mongodb://localhost:27017/track"
Expand All @@ -18,23 +18,22 @@ def init_app(app):

A_DAY = 60 * 60 * 24


class ProductionConfig(Config):

if os.environ.get("TRACKER_KEYVAULT_URI", None) != None:
if os.environ.get("TRACKER_KEYVAULT_URI", None) is not None and os.environ.get("SECRET_NAME_RO", None) is not None:
KV_URI = os.environ.get("TRACKER_KEYVAULT_URI")
SECRET_NAME = os.environ.get("SECRET_NAME_RO")
creds = MSIAuthentication(resource='https://vault.azure.net')
keyvault = KeyVaultClient(creds)
KV_URI = os.environ.get("TRACKER_KEYVAULT_URI")
MONGO_URI = keyvault.get_secret(KV_URI, "cosmosdb-ro-conn-string", "").value
MONGO_URI = keyvault.get_secret(KV_URI, SECRET_NAME, "").value

else:
MONGO_URI = os.environ.get("TRACKER_MONGO_URI", None)


CACHE_TYPE = "filesystem"
CACHE_DIR = os.environ.get("TRACKER_CACHE_DIR", "./.cache")
CACHE_DEFAULT_TIMEOUT = int(os.environ.get("TRACKER_CACHE_TIMEOUT", A_DAY))


@staticmethod
def init_app(app):
Config.init_app(app)
Expand Down

0 comments on commit 1ea740a

Please sign in to comment.