Beispiel #1
0
def app_sessions(app):
    app.url_map.strict_slashes = False
    app.db = SQLAlchemyDriver(app.config["DB"])
    migrate(app.db)
    session = flask_scoped_session(app.db.Session, app)  # noqa
    app.storage_manager = StorageManager(
        app.config["STORAGE_CREDENTIALS"], logger=app.logger
    )
    enabled_idp_ids = app.config["ENABLED_IDENTITY_PROVIDERS"]["providers"].keys()
    # Add OIDC client for Google if configured.
    configured_google = (
        "OPENID_CONNECT" in app.config and "google" in app.config["OPENID_CONNECT"]
    )
    if configured_google:
        app.google_client = GoogleClient(
            app.config["OPENID_CONNECT"]["google"],
            HTTP_PROXY=app.config.get("HTTP_PROXY"),
            logger=app.logger,
        )
    # Add OIDC client for multi-tenant fence if configured.
    configured_fence = (
        "OPENID_CONNECT" in app.config
        and "fence" in app.config["OPENID_CONNECT"]
        and "fence" in enabled_idp_ids
    )
    if configured_fence:
        app.fence_client = OAuthClient(**app.config["OPENID_CONNECT"]["fence"])
    app.session_interface = UserSessionInterface()
    if app.config.get("ARBORIST"):
        app.arborist = ArboristClient(arborist_base_url=app.config["ARBORIST"])
Beispiel #2
0
def app_sessions(app):
    app.url_map.strict_slashes = False
    app.db = SQLAlchemyDriver(config["DB"])

    # TODO: we will make a more robust migration system external from the application
    #       initialization soon
    if config["ENABLE_DB_MIGRATION"]:
        logger.info("Running database migration...")
        migrate(app.db)
        logger.info("Done running database migration.")
    else:
        logger.info("NOT running database migration.")

    session = flask_scoped_session(app.db.Session, app)  # noqa
    app.session_interface = UserSessionInterface()
Beispiel #3
0
def app_sessions(app):
    app.url_map.strict_slashes = False
    app.db = SQLAlchemyDriver(app.config['DB'])
    migrate(app.db)
    session = flask_scoped_session(app.db.Session, app)  # noqa
    app.jinja_env.globals['csrf_token'] = generate_csrf_token
    app.storage_manager = StorageManager(
        app.config['STORAGE_CREDENTIALS'],
        logger=app.logger
    )
    enabled_idp_ids = (
        fence.settings
        .ENABLED_IDENTITY_PROVIDERS['providers']
        .keys()
    )
    # Add OIDC client for Google if configured.
    configured_google = (
        'OPENID_CONNECT' in app.config
        and 'google' in app.config['OPENID_CONNECT']
        and 'google' in enabled_idp_ids
    )
    if configured_google:
        app.google_client = GoogleClient(
            app.config['OPENID_CONNECT']['google'],
            HTTP_PROXY=app.config.get('HTTP_PROXY'),
            logger=app.logger
        )
    # Add OIDC client for multi-tenant fence if configured.
    configured_fence = (
        'OPENID_CONNECT' in app.config
        and 'fence' in app.config['OPENID_CONNECT']
        and 'fence' in enabled_idp_ids
    )
    if configured_fence:
        app.fence_client = OAuthClient(**app.config['OPENID_CONNECT']['fence'])
    app.session_interface = UserSessionInterface()
Beispiel #4
0
def app_sessions(app):
    app.url_map.strict_slashes = False
    app.db = SQLAlchemyDriver(config["DB"])
    migrate(app.db)
    session = flask_scoped_session(app.db.Session, app)  # noqa
    app.session_interface = UserSessionInterface()
Beispiel #5
0
def migrate_database(db):
    driver = SQLAlchemyDriver(db)
    migrate(driver)
    logger.info("Done.")
Beispiel #6
0
def migrate_database(db):
    driver = SQLAlchemyDriver(db)
    migrate(driver)
    print("Done.")