Ejemplo n.º 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"])
Ejemplo n.º 2
0
def _setup_oidc_clients(app):
    if config["LOGIN_OPTIONS"]:
        enabled_idp_ids = [option["idp"] for option in config["LOGIN_OPTIONS"]]
    else:
        # fall back on "providers"
        enabled_idp_ids = list(
            config.get("ENABLED_IDENTITY_PROVIDERS", {}).get("providers",
                                                             {}).keys())
    oidc = config.get("OPENID_CONNECT", {})

    # Add OIDC client for Google if configured.
    if "google" in oidc:
        app.google_client = GoogleClient(
            config["OPENID_CONNECT"]["google"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for ORCID if configured.
    if "orcid" in oidc:
        app.orcid_client = ORCIDClient(
            config["OPENID_CONNECT"]["orcid"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for RAS if configured.
    if "ras" in oidc:
        app.ras_client = RASClient(
            oidc["ras"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for Synapse if configured.
    if "synapse" in oidc:
        app.synapse_client = SynapseClient(oidc["synapse"],
                                           HTTP_PROXY=config.get("HTTP_PROXY"),
                                           logger=logger)

    # Add OIDC client for Microsoft if configured.
    if "microsoft" in oidc:
        app.microsoft_client = MicrosoftClient(
            config["OPENID_CONNECT"]["microsoft"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for Amazon Cognito if configured.
    if "cognito" in oidc:
        app.cognito_client = CognitoClient(oidc["cognito"],
                                           HTTP_PROXY=config.get("HTTP_PROXY"),
                                           logger=logger)

    # Add OIDC client for multi-tenant fence if configured.
    configured_fence = "fence" in oidc and "fence" in enabled_idp_ids
    if configured_fence:
        app.fence_client = OAuthClient(**config["OPENID_CONNECT"]["fence"])
Ejemplo n.º 3
0
def _setup_oidc_clients(app):
    oidc = config.get("OPENID_CONNECT", {})

    # Add OIDC client for Google if configured.
    if "google" in oidc:
        app.google_client = GoogleClient(
            config["OPENID_CONNECT"]["google"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for ORCID if configured.
    if "orcid" in oidc:
        app.orcid_client = ORCIDClient(
            config["OPENID_CONNECT"]["orcid"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for RAS if configured.
    if "ras" in oidc:
        app.ras_client = RASClient(
            oidc["ras"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for Synapse if configured.
    if "synapse" in oidc:
        app.synapse_client = SynapseClient(oidc["synapse"],
                                           HTTP_PROXY=config.get("HTTP_PROXY"),
                                           logger=logger)

    # Add OIDC client for Microsoft if configured.
    if "microsoft" in oidc:
        app.microsoft_client = MicrosoftClient(
            config["OPENID_CONNECT"]["microsoft"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for Amazon Cognito if configured.
    if "cognito" in oidc:
        app.cognito_client = CognitoClient(oidc["cognito"],
                                           HTTP_PROXY=config.get("HTTP_PROXY"),
                                           logger=logger)

    # Add OIDC client for multi-tenant fence if configured.
    if "fence" in oidc:
        app.fence_client = OAuthClient(**config["OPENID_CONNECT"]["fence"])
Ejemplo n.º 4
0
def _setup_oidc_clients(app):
    enabled_idp_ids = list(
        config["ENABLED_IDENTITY_PROVIDERS"]["providers"].keys())
    oidc = config.get("OPENID_CONNECT", {})

    # Add OIDC client for Google if configured.
    configured_google = ("OPENID_CONNECT" in config
                         and "google" in config["OPENID_CONNECT"])
    if configured_google:
        app.google_client = GoogleClient(
            config["OPENID_CONNECT"]["google"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for ORCID if configured.
    configured_orcid = ("OPENID_CONNECT" in config
                        and "orcid" in config["OPENID_CONNECT"])
    if configured_orcid:
        app.orcid_client = ORCIDClient(
            config["OPENID_CONNECT"]["orcid"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for Synapse if configured.
    if "synapse" in oidc:
        app.synapse_client = SynapseClient(oidc["synapse"],
                                           HTTP_PROXY=config.get("HTTP_PROXY"),
                                           logger=logger)

    # Add OIDC client for Microsoft if configured.
    configured_microsoft = ("OPENID_CONNECT" in config
                            and "microsoft" in config["OPENID_CONNECT"])
    if configured_microsoft:
        app.microsoft_client = MicrosoftClient(
            config["OPENID_CONNECT"]["microsoft"],
            HTTP_PROXY=config.get("HTTP_PROXY"),
            logger=logger,
        )

    # Add OIDC client for multi-tenant fence if configured.
    configured_fence = ("OPENID_CONNECT" in config
                        and "fence" in config["OPENID_CONNECT"]
                        and "fence" in enabled_idp_ids)
    if configured_fence:
        app.fence_client = OAuthClient(**config["OPENID_CONNECT"]["fence"])
Ejemplo n.º 5
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()