Пример #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 = 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)
Пример #2
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
Пример #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)
Пример #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 = 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)
Пример #5
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)
Пример #6
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
Пример #7
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
Пример #8
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)
Пример #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 = 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)
Пример #10
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
Пример #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 = 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')
Пример #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 = 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)