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 = 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.º 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 = 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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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.º 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 = 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.º 10
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.º 11
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.º 12
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.º 13
0
def phone_init_app(name, config):
    """
    Create an instance of an eduid phone app.

    First, it will load the configuration from phone.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.phone.views import phone_views
    app.register_blueprint(phone_views)

    app = am.init_relay(app, 'eduid_phone')
    app = msg.init_relay(app)

    app.private_userdb = PhoneProofingUserDB(app.config['MONGO_URI'])
    app.proofing_statedb = PhoneProofingStateDB(app.config['MONGO_URI'])
    app.proofing_log = ProofingLog(app.config['MONGO_URI'])

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

    return app
Exemplo n.º 14
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