Exemplo n.º 1
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = ResetPasswordConfig.init_config(ns='webapp', app_name=name, test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: ResetPasswordConfig = cast(ResetPasswordConfig, self.config)  # type: ignore

        # Register views
        from eduid_webapp.reset_password.views.reset_password import reset_password_views
        from eduid_webapp.reset_password.views.change_password import change_password_views

        self.register_blueprint(change_password_views)
        self.register_blueprint(reset_password_views)

        # Register view path that should not be authorized
        no_authn_views(self, [r'/reset.*', r'/new-password/?'])

        # Init celery
        msg.init_relay(self)
        am.init_relay(self, 'eduid_reset_password')
        mail_relay.init_relay(self)
        translation.init_babel(self)

        # Init dbs
        self.private_userdb = ResetPasswordUserDB(self.config.mongo_uri)
        self.password_reset_state_db = ResetPasswordStateDB(self.config.mongo_uri)
        self.proofing_log = ProofingLog(self.config.mongo_uri)
        self.authninfo_db = AuthnInfoDB(self.config.mongo_uri)
Exemplo n.º 2
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = SecurityConfig.init_config(ns='webapp',
                                                 app_name=name,
                                                 test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: SecurityConfig = cast(SecurityConfig,
                                           self.config)  # type: ignore

        from eduid_webapp.security.views.security import security_views
        from eduid_webapp.security.views.u2f import u2f_views
        from eduid_webapp.security.views.webauthn import webauthn_views
        from eduid_webapp.security.views.reset_password import reset_password_views

        self.register_blueprint(security_views)
        self.register_blueprint(u2f_views)
        self.register_blueprint(webauthn_views)
        self.register_blueprint(reset_password_views)

        # Register view path that should not be authorized
        no_authn_views(self, ['/reset-password.*'])

        am.init_relay(self, f'eduid_{name}')
        msg.init_relay(self)
        mail_relay.init_relay(self)
        translation.init_babel(self)

        self.private_userdb = SecurityUserDB(self.config.mongo_uri)
        self.authninfo_db = AuthnInfoDB(self.config.mongo_uri)
        self.password_reset_state_db = PasswordResetStateDB(
            self.config.mongo_uri)
        self.proofing_log = ProofingLog(self.config.mongo_uri)
Exemplo n.º 3
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = OIDCProofingConfig.init_config(ns='webapp', app_name=name, test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: OIDCProofingConfig = cast(OIDCProofingConfig, self.config)  # type: ignore

        from eduid_webapp.oidc_proofing.views import oidc_proofing_views

        self.register_blueprint(oidc_proofing_views)

        # Register view path that should not be authorized
        no_authn_views(self, ['/authorization-response'])

        # Initialize the oidc_client after views to be able to set correct redirect_uris
        oidc.init_client(self)

        # Init celery
        msg.init_relay(self)
        am.init_relay(self, 'eduid_oidc_proofing')
        mail_relay.init_relay(self)

        # Init babel
        translation.init_babel(self)

        # Initialize db
        self.private_userdb = OidcProofingUserDB(self.config.mongo_uri)
        self.proofing_statedb = OidcProofingStateDB(self.config.mongo_uri)
        self.proofing_log = ProofingLog(self.config.mongo_uri)
Exemplo n.º 4
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = OrcidConfig.init_config(ns='webapp',
                                              app_name=name,
                                              test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: OrcidConfig = cast(OrcidConfig,
                                        self.config)  # type: ignore

        # Register views
        from eduid_webapp.orcid.views import orcid_views

        self.register_blueprint(orcid_views)

        # Init dbs
        self.private_userdb = OrcidProofingUserDB(self.config.mongo_uri)
        self.proofing_statedb = OrcidProofingStateDB(self.config.mongo_uri)
        self.proofing_log = ProofingLog(self.config.mongo_uri)

        # Init celery
        am.init_relay(self, 'eduid_orcid')

        # Initialize the oidc_client
        oidc.init_client(self)
Exemplo n.º 5
0
def pd_init_app(name, config):
    """
    Create an instance of an eduid personal data app.

    First, it will load the configuration from personal_data.settings.common
    then any settings given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    all needed blueprints will be registered with it,
    and finally the app is configured with the necessary db connections.

    :param name: The name of the instance, it will affect the configuration loaded.
    :type name: str
    :param config: any additional configuration settings. Specially useful
                   in test cases
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)
    app.config.update(config)

    from eduid_webapp.personal_data.views import pd_views
    app.register_blueprint(pd_views)

    app = am.init_relay(app, 'eduid_personal_data')

    app.private_userdb = PersonalDataUserDB(app.config['MONGO_URI'])

    app.logger.info('Init {} app...'.format(name))

    return app
Exemplo n.º 6
0
def init_lookup_mobile_proofing_app(name, config=None):
    """
    :param name: The name of the instance, it will affect the configuration loaded.
    :param config: any additional configuration settings. Specially useful
                   in test cases

    :type name: str
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)

    # Register views
    from eduid_webapp.lookup_mobile_proofing.views import mobile_proofing_views
    app.register_blueprint(mobile_proofing_views)

    # Init dbs
    app.private_userdb = LookupMobileProofingUserDB(app.config['MONGO_URI'])
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

    # Init celery
    app = lookup_mobile_relay.init_relay(app)
    app = msg.init_relay(app)
    app = am.init_relay(app, 'eduid_lookup_mobile_proofing')

    app.logger.info('{!s} initialized'.format(name))
    return app
Exemplo n.º 7
0
def init_orcid_app(name, config=None):
    """
    :param name: The name of the instance, it will affect the configuration loaded.
    :param config: any additional configuration settings. Specially useful
                   in test cases

    :type name: str
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)

    # Register views
    from eduid_webapp.orcid.views import orcid_views
    app.register_blueprint(orcid_views)

    # Init dbs
    app.private_userdb = OrcidProofingUserDB(app.config['MONGO_URI'])
    app.proofing_statedb = OrcidProofingStateDB(app.config['MONGO_URI'])
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

    # Init celery
    app = am.init_relay(app, 'eduid_orcid')

    # Initialize the oidc_client
    app = oidc.init_client(app)

    app.logger.info('{!s} initialized'.format(name))
    return app
Exemplo n.º 8
0
def init_letter_proofing_app(name, config=None):
    """
    :param name: The name of the instance, it will affect the configuration loaded.
    :param config: any additional configuration settings. Specially useful
                   in test cases

    :type name: str
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)

    # Register views
    from eduid_webapp.letter_proofing.views import letter_proofing_views
    app.register_blueprint(letter_proofing_views,
                           url_prefix=app.config.get('APPLICATION_ROOT', None))

    # Init dbs
    app.proofing_statedb = LetterProofingStateDB(app.config['MONGO_URI'])
    app.proofing_userdb = LetterProofingUserDB(app.config['MONGO_URI'])

    # Init celery
    app = msg.init_relay(app)
    app = am.init_relay(app, 'eduid_letter_proofing')

    # Initiate external modules
    app.ekopost = Ekopost(app)

    app.logger.info('{!s} initialized'.format(name))
    return app
Exemplo n.º 9
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = PhoneConfig.init_config(ns='webapp', app_name=name, test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: PhoneConfig = cast(PhoneConfig, self.config)  # type: ignore

        from eduid_webapp.phone.views import phone_views

        self.register_blueprint(phone_views)

        am.init_relay(self, 'eduid_phone')
        msg.init_relay(self)

        self.private_userdb = PhoneProofingUserDB(self.config.mongo_uri)
        self.proofing_statedb = PhoneProofingStateDB(self.config.mongo_uri)
        self.proofing_log = ProofingLog(self.config.mongo_uri)
Exemplo n.º 10
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = FlaskConfig.init_config(ns='webapp',
                                              app_name=name,
                                              test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: FlaskConfig = cast(FlaskConfig,
                                        self.config)  # type: ignore

        from eduid_webapp.personal_data.views import pd_views

        self.register_blueprint(pd_views)

        am.init_relay(self, 'eduid_personal_data')

        self.private_userdb = PersonalDataUserDB(self.config.mongo_uri)
Exemplo n.º 11
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = SignupConfig.init_config(ns='webapp', app_name=name, test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: SignupConfig = cast(SignupConfig, self.config)  # type: ignore

        from eduid_webapp.signup.views import signup_views

        self.register_blueprint(signup_views)

        am.init_relay(self, 'eduid_signup')
        mail_relay.init_relay(self)
        translation.init_babel(self)

        self.private_userdb = SignupUserDB(self.config.mongo_uri, 'eduid_signup')
        self.proofing_log = ProofingLog(self.config.mongo_uri)
Exemplo n.º 12
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = MobileProofingConfig.init_config(ns='webapp',
                                                       app_name=name,
                                                       test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: MobileProofingConfig = cast(MobileProofingConfig,
                                                 self.config)  # type: ignore

        # Register views
        from eduid_webapp.lookup_mobile_proofing.views import mobile_proofing_views

        self.register_blueprint(mobile_proofing_views)

        # Init dbs
        self.private_userdb = LookupMobileProofingUserDB(self.config.mongo_uri)
        self.proofing_log = ProofingLog(self.config.mongo_uri)

        # Init celery
        lookup_mobile_relay.init_relay(self)
        msg.init_relay(self)
        am.init_relay(self, 'eduid_lookup_mobile_proofing')
Exemplo n.º 13
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = ActionsConfig.init_config(ns='webapp',
                                                app_name=name,
                                                test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: ActionsConfig = cast(ActionsConfig,
                                          self.config)  # type: ignore

        from eduid_webapp.actions.views import actions_views

        self.register_blueprint(actions_views)

        am.init_relay(self, f'eduid_{name}')

        self.actions_db = ActionDB(self.config.mongo_uri)

        self.plugins = PluginsRegistry(self)
        for plugin in self.plugins.values():
            plugin.includeme(self)

        self.get_tous = types.MethodType(_get_tous, self)
Exemplo n.º 14
0
def security_init_app(name, config):
    """
    Create an instance of an eduid security (passwords) app.

    First, it will load the configuration from security.settings.common
    then any settings given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    all needed blueprints will be registered with it,
    and finally the app is configured with the necessary db connections.

    :param name: The name of the instance, it will affect the configuration loaded.
    :type name: str
    :param config: any additional configuration settings. Specially useful
                   in test cases
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)
    app.config.update(config)

    from eduid_webapp.security.views.security import security_views
    from eduid_webapp.security.views.u2f import u2f_views
    from eduid_webapp.security.views.webauthn import webauthn_views
    from eduid_webapp.security.views.reset_password import reset_password_views
    app.register_blueprint(security_views)
    app.register_blueprint(u2f_views)
    app.register_blueprint(webauthn_views)
    app.register_blueprint(reset_password_views)

    # Register view path that should not be authorized
    app = no_authn_views(app, ['/reset-password.*'])

    app = am.init_relay(app, 'eduid_security')
    app = msg.init_relay(app)
    app = mail_relay.init_relay(app)
    app = translation.init_babel(app)

    app.private_userdb = SecurityUserDB(app.config['MONGO_URI'])
    app.authninfo_db = AuthnInfoDB(app.config['MONGO_URI'])
    app.password_reset_state_db = PasswordResetStateDB(app.config['MONGO_URI'])
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

    app.logger.info('Init {} app...'.format(name))

    return app
Exemplo n.º 15
0
    def __init__(self, name: str, config: dict, **kwargs):

        # Load acs actions on app init
        from . import acs_actions

        # Make sure pycharm doesn't think the import above is unused and removes it
        if acs_actions.__author__:
            pass

        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = EidasConfig.init_config(ns='webapp',
                                              app_name=name,
                                              test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: EidasConfig = cast(EidasConfig,
                                        self.config)  # type: ignore

        self.saml2_config = get_saml2_config(self.config.saml2_settings_module)

        # Register views
        from eduid_webapp.eidas.views import eidas_views

        self.register_blueprint(eidas_views)

        # Register view path that should not be authorized
        no_authn_views(
            self, ['/saml2-metadata', '/saml2-acs', '/mfa-authentication'])

        # Init dbs
        self.private_userdb = EidasProofingUserDB(self.config.mongo_uri)
        self.proofing_log = ProofingLog(self.config.mongo_uri)

        # Init celery
        am.init_relay(self, 'eduid_eidas')
        msg.init_relay(self)
Exemplo n.º 16
0
    def __init__(self, name: str, config: dict, **kwargs):
        # Initialise type of self.config before any parent class sets a precedent to mypy
        self.config = LetterProofingConfig.init_config(ns='webapp',
                                                       app_name=name,
                                                       test_config=config)
        super().__init__(name, **kwargs)
        # cast self.config because sometimes mypy thinks it is a FlaskConfig after super().__init__()
        self.config: LetterProofingConfig = cast(LetterProofingConfig,
                                                 self.config)  # type: ignore

        # Register views
        from eduid_webapp.letter_proofing.views import letter_proofing_views

        self.register_blueprint(letter_proofing_views)

        # Init dbs
        self.private_userdb = LetterProofingUserDB(self.config.mongo_uri)
        self.proofing_statedb = LetterProofingStateDB(self.config.mongo_uri)
        self.proofing_log = ProofingLog(self.config.mongo_uri)
        # Init celery
        msg.init_relay(self)
        am.init_relay(self, 'eduid_letter_proofing')
        # Initiate external modules
        self.ekopost = Ekopost(self)
Exemplo n.º 17
0
def init_oidc_proofing_app(name, config):
    """
    Create an instance of an oidc proofing app.

    First, it will load the configuration from oidc_proofing.settings.common then any settings
    given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    and finally all needed blueprints will be registered with it.

    :param name: The name of the instance, it will affect the configuration loaded.
    :param config: any additional configuration settings. Specially useful
                   in test cases

    :type name: str
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)
    app.config.update(config)

    from eduid_webapp.oidc_proofing.views import oidc_proofing_views
    app.register_blueprint(oidc_proofing_views)

    # Register view path that should not be authorized
    app = no_authn_views(app, ['/authorization-response'])

    # Initialize the oidc_client after views to be able to set correct redirect_uris
    app.oidc_client = init_oidc_client(app)

    # Init celery
    app = msg.init_relay(app)
    app = am.init_relay(app, 'eduid_oidc_proofing')
    app = mail_relay.init_relay(app)

    # Init babel
    app = translation.init_babel(app)

    # Initialize db
    app.private_userdb = OidcProofingUserDB(app.config['MONGO_URI'])
    app.proofing_statedb = OidcProofingStateDB(app.config['MONGO_URI'])
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

    return app
Exemplo n.º 18
0
def security_init_app(name, config):
    """
    Create an instance of an eduid security (passwords) app.

    First, it will load the configuration from security.settings.common
    then any settings given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    all needed blueprints will be registered with it,
    and finally the app is configured with the necessary db connections.

    :param name: The name of the instance, it will affect the configuration loaded.
    :type name: str
    :param config: any additional configuration settings. Specially useful
                   in test cases
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)
    app.config.update(config)

    from eduid_webapp.security.views.security import security_views
    from eduid_webapp.security.views.u2f import u2f_views
    from eduid_webapp.security.views.reset_password import reset_password_views
    app.register_blueprint(security_views)
    app.register_blueprint(u2f_views)
    app.register_blueprint(reset_password_views)

    # Register view path that should not be authorized
    app = no_authn_views(app, ['/reset-password.*'])

    app = am.init_relay(app, 'eduid_security')
    app = msg.init_relay(app)
    app = mail_relay.init_relay(app)
    app = translation.init_babel(app)

    app.private_userdb = SecurityUserDB(app.config['MONGO_URI'])
    app.authninfo_db = AuthnInfoDB(app.config['MONGO_URI'])
    app.password_reset_state_db = PasswordResetStateDB(app.config['MONGO_URI'])
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

    app.logger.info('Init {} app...'.format(name))

    return app
Exemplo n.º 19
0
def actions_init_app(name, config):
    """
    Create an instance of an eduid actions app.

    First, it will load the configuration from actions.settings.common
    then any settings given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    all needed blueprints will be registered with it,
    and finally the app is configured with the necessary db connections.

    Note that we use UnAuthnApp as the class for the Flask app,
    since the actions app is used unauthenticated.

    :param name: The name of the instance, it will affect the configuration loaded.
    :type name: str
    :param config: any additional configuration settings. Specially useful
                   in test cases
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config, app_class=Flask)
    app.config.update(config)

    from eduid_webapp.actions.views import actions_views
    app.register_blueprint(actions_views)

    app = am.init_relay(app, 'eduid_actions')

    app.actions_db = ActionDB(app.config['MONGO_URI'])

    app.plugins = PluginsRegistry(app)
    for plugin in app.plugins.values():
        plugin.includeme(app)

    app.get_tous = types.MethodType(_get_tous, app)

    app.logger.info('Init {} app...'.format(name))

    return app
Exemplo n.º 20
0
def actions_init_app(name, config):
    """
    Create an instance of an eduid actions app.

    First, it will load the configuration from actions.settings.common
    then any settings given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    all needed blueprints will be registered with it,
    and finally the app is configured with the necessary db connections.

    Note that we use UnAuthnApp as the class for the Flask app,
    since the actions app is used unauthenticated.

    :param name: The name of the instance, it will affect the configuration loaded.
    :type name: str
    :param config: any additional configuration settings. Specially useful
                   in test cases
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config, app_class=UnAuthnApp)
    app.config.update(config)
    app.config['CELERY_CONFIG']['MONGO_URI'] = app.config['MONGO_URI']

    from eduid_webapp.actions.views import actions_views
    app.register_blueprint(actions_views)

    app = am.init_relay(app, 'eduid_actions')

    app.actions_db = ActionDB(app.config['MONGO_URI'])

    app.plugins = PluginsRegistry(app)
    for plugin in app.plugins.values():
        plugin.includeme(app)

    app.logger.info('Init {} app...'.format(name))

    return app
Exemplo n.º 21
0
def signup_init_app(name, config):
    """
    Create an instance of an eduid signup app.

    First, it will load the configuration from signup.settings.common
    then any settings given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    all needed blueprints will be registered with it,
    and finally the app is configured with the necessary db connections.

    Note that we use UnAuthnApp as the class for the Flask app,
    since obviously the signup app is used unauthenticated.

    :param name: The name of the instance, it will affect the configuration loaded.
    :type name: str
    :param config: any additional configuration settings. Specially useful
                   in test cases
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config, app_class=Flask)
    app.config.update(config)

    from eduid_webapp.signup.views import signup_views
    app.register_blueprint(signup_views)

    app = am.init_relay(app, 'eduid_signup')
    app = mail_relay.init_relay(app)
    app = translation.init_babel(app)

    app.private_userdb = SignupUserDB(app.config['MONGO_URI'], 'eduid_signup')
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

    app.logger.info('Init {} app...'.format(name))

    return app
Exemplo n.º 22
0
def email_init_app(name, config):
    """
    Create an instance of an eduid email app.

    First, it will load the configuration from email.settings.common
    then any settings given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    all needed blueprints will be registered with it,
    and finally the app is configured with the necessary db connections.

    :param name: The name of the instance, it will affect the configuration loaded.
    :type name: str
    :param config: any additional configuration settings. Specially useful
                   in test cases
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)
    app.config.update(config)

    from eduid_webapp.email.views import email_views
    app.register_blueprint(email_views)

    app = am.init_relay(app, 'eduid_email')
    app = mail_relay.init_relay(app)
    app = translation.init_babel(app)

    app.private_userdb = EmailProofingUserDB(app.config['MONGO_URI'])
    app.proofing_statedb = EmailProofingStateDB(app.config['MONGO_URI'])
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

    app.logger.info('Init {} app...'.format(name))

    return app
Exemplo n.º 23
0
def pd_init_app(name, config):
    """
    Create an instance of an eduid personal data app.

    First, it will load the configuration from personal_data.settings.common
    then any settings given in the `config` param.

    Then, the app instance will be updated with common stuff by `eduid_init_app`,
    all needed blueprints will be registered with it,
    and finally the app is configured with the necessary db connections.

    :param name: The name of the instance, it will affect the configuration loaded.
    :type name: str
    :param config: any additional configuration settings. Specially useful
                   in test cases
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """

    app = eduid_init_app(name, config)
    app.config.update(config)

    from eduid_webapp.personal_data.views import pd_views
    app.register_blueprint(pd_views,
                           url_prefix=app.config.get('APPLICATION_ROOT', None))

    # XXX: Maybe we should extend eduid-dashboard or write a new amp to be able to narrow the
    # XXX: attributes that can be changed by a sync call
    app = am.init_relay(app, 'eduid_dashboard')

    app.dashboard_userdb = DashboardUserDB(app.config['MONGO_URI'])

    app.logger.info('Init {} app...'.format(name))

    return app
Exemplo n.º 24
0
def init_eidas_app(name, config=None):
    """
    :param name: The name of the instance, it will affect the configuration loaded.
    :param config: any additional configuration settings. Specially useful
                   in test cases

    :type name: str
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """
    # Load acs actions on app init
    from . import acs_actions

    app = eduid_init_app(name, config)

    app.saml2_config = get_saml2_config(app.config['SAML2_SETTINGS_MODULE'])
    app.config['SAML2_CONFIG'] = app.saml2_config

    # Register views
    from eduid_webapp.eidas.views import eidas_views
    app.register_blueprint(eidas_views)

    # Register view path that should not be authorized
    app = no_authn_views(app, ['/saml2-metadata', '/saml2-acs', '/mfa-authentication'])

    # Init dbs
    app.private_userdb = EidasProofingUserDB(app.config['MONGO_URI'])
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

    # Init celery
    app = am.init_relay(app, 'eduid_eidas')
    app = msg.init_relay(app)

    app.logger.info('{!s} initialized'.format(name))
    return app