mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 05:08:25 -04:00
Ensured credstash is located only with the wsgi/gunicorn code.
This commit is contained in:
@@ -13,7 +13,6 @@ from app.its_dangerous_session import ItsdangerousSessionInterface
|
|||||||
import app.proxy_fix
|
import app.proxy_fix
|
||||||
from config import configs
|
from config import configs
|
||||||
from utils import logging
|
from utils import logging
|
||||||
from credstash import getAllSecrets
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
@@ -22,13 +21,13 @@ csrf = CsrfProtect()
|
|||||||
admin_api_client = AdminAPIClient()
|
admin_api_client = AdminAPIClient()
|
||||||
|
|
||||||
|
|
||||||
def create_app(config_name):
|
def create_app(config_name, config_overrides=None):
|
||||||
application = Flask(__name__)
|
application = Flask(__name__)
|
||||||
|
|
||||||
application.config['NOTIFY_ADMIN_ENVIRONMENT'] = config_name
|
application.config['NOTIFY_ADMIN_ENVIRONMENT'] = config_name
|
||||||
application.config.from_object(configs[config_name])
|
application.config.from_object(configs[config_name])
|
||||||
|
init_app(application, config_overrides)
|
||||||
db.init_app(application)
|
db.init_app(application)
|
||||||
init_app(application)
|
|
||||||
init_csrf(application)
|
init_csrf(application)
|
||||||
logging.init_app(application)
|
logging.init_app(application)
|
||||||
|
|
||||||
@@ -71,17 +70,15 @@ def init_csrf(application):
|
|||||||
abort(400, reason)
|
abort(400, reason)
|
||||||
|
|
||||||
|
|
||||||
def init_app(app):
|
def init_app(app, config_overrides):
|
||||||
for key, value in app.config.items():
|
for key, value in app.config.items():
|
||||||
if key in os.environ:
|
if key in os.environ:
|
||||||
app.config[key] = convert_to_boolean(os.environ[key])
|
app.config[key] = convert_to_boolean(os.environ[key])
|
||||||
|
|
||||||
if app.config['NOTIFY_ADMIN_ENVIRONMENT'] == 'live':
|
if config_overrides:
|
||||||
secrets = getAllSecrets(region="eu-west-1")
|
|
||||||
|
|
||||||
for key in app.config.keys():
|
for key in app.config.keys():
|
||||||
if key in secrets:
|
if key in config_overrides:
|
||||||
app.config[key] = secrets[key]
|
app.config[key] = config_overrides[key]
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_global_template_variables():
|
def inject_global_template_variables():
|
||||||
|
|||||||
5
db.py
5
db.py
@@ -1,8 +1,11 @@
|
|||||||
from flask.ext.script import Manager, Server
|
from flask.ext.script import Manager, Server
|
||||||
from flask_migrate import Migrate, MigrateCommand
|
from flask_migrate import Migrate, MigrateCommand
|
||||||
from app import create_app, db
|
from app import create_app, db
|
||||||
|
from credstash import getAllSecrets
|
||||||
|
|
||||||
application = create_app('live')
|
secrets = getAllSecrets(region="eu-west-1")
|
||||||
|
|
||||||
|
application = create_app('live', secrets)
|
||||||
|
|
||||||
manager = Manager(application)
|
manager = Manager(application)
|
||||||
migrate = Migrate(application, db)
|
migrate = Migrate(application, db)
|
||||||
|
|||||||
5
wsgi.py
5
wsgi.py
@@ -1,6 +1,9 @@
|
|||||||
from app import create_app
|
from app import create_app
|
||||||
|
from credstash import getAllSecrets
|
||||||
|
|
||||||
application = create_app('live')
|
secrets = getAllSecrets(region="eu-west-1")
|
||||||
|
|
||||||
|
application = create_app('live', secrets)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
application.run()
|
application.run()
|
||||||
|
|||||||
Reference in New Issue
Block a user