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
def support_init_app(name, config): """ Create an instance of an eduid support app. First, it will load the configuration from support.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. :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.support.views import support_views app.register_blueprint(support_views) app.support_user_db = SupportUserDB(app.config['MONGO_URI']) app.support_authn_db = SupportAuthnInfoDB(app.config['MONGO_URI']) app.support_verification_db = SupportVerificationsDB(app.config['MONGO_URI']) return app
def authn_init_app(name, config): """ Create an instance of an authentication app. First, it will load the configuration from the file system, according to the logic in `eduid_common.config.parsers.INIConfigParser`, and update it with 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 file loaded from the filesystem. :type name: str :param config: any additional configuration settings. Specially useful in test cases :type config: dict :return: the flask app :rtype: flask.Flask """ from . import acs_actions app = eduid_init_app(name, config, app_class=Flask) app.saml2_config = get_saml2_config(app.config['SAML2_SETTINGS_MODULE']) app.config['SAML2_CONFIG'] = app.saml2_config from eduid_webapp.authn.views import authn_views app.register_blueprint(authn_views) app.logger.info('Init {} app...'.format(name)) return app
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
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
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
def support_init_app(name, config): """ Create an instance of an eduid support app. First, it will load the configuration from support.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. :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) if app.config.get('TOKEN_SERVICE_URL_LOGOUT') is None: app.config['TOKEN_SERVICE_URL_LOGOUT'] = urlappend( app.config['TOKEN_SERVICE_URL'], 'logout') from eduid_webapp.support.views import support_views app.register_blueprint(support_views) app.support_user_db = db.SupportUserDB(app.config['MONGO_URI']) app.support_authn_db = db.SupportAuthnInfoDB(app.config['MONGO_URI']) app.support_proofing_log_db = db.SupportProofingLogDB( app.config['MONGO_URI']) app.support_signup_db = db.SupportSignupUserDB(app.config['MONGO_URI']) app.support_actions_db = db.SupportActionsDB(app.config['MONGO_URI']) app.support_letter_proofing_db = db.SupportLetterProofingDB( app.config['MONGO_URI']) app.support_oidc_proofing_db = db.SupportOidcProofingDB( app.config['MONGO_URI']) app.support_email_proofing_db = db.SupportEmailProofingDB( app.config['MONGO_URI']) app.support_phone_proofing_db = db.SupportPhoneProofingDB( app.config['MONGO_URI']) app = register_template_funcs(app) app.logger.info('Init {} app...'.format(name)) return app
def oidc_proofing_init_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_class=Flask) app.config.update(config) from eduid_webapp.oidc_proofing.views import oidc_proofing_views app.register_blueprint(oidc_proofing_views) # Initialize the oidc_client after views to be able to set correct redirect_uris app.oidc_client = init_oidc_client(app) # Initialize db app.proofing_statedb = OidcProofingStateDB(app.config['MONGO_URI']) app.proofdb = ProofDB(app.config['MONGO_URI']) # TODO: Move to base app @webargs_flaskparser.error_handler def handle_webargs_exception(error): app.logger.error('ApiException {!r}'.format(error)) raise (ApiException(error.messages, error.status_code)) # TODO: Move to base app @app.errorhandler(ApiException) def handle_flask_exception(error): app.logger.error('ApiException {!r}'.format(error)) response = jsonify(error.to_dict()) response.status_code = error.status_code return response return app
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
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
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
def support_init_app(name, config): """ Create an instance of an eduid support app. First, it will load the configuration from support.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. :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.support.views import support_views app.register_blueprint(support_views, url_prefix=app.config.get('APPLICATION_ROOT', None)) app.support_user_db = db.SupportUserDB(app.config['MONGO_URI']) app.support_authn_db = db.SupportAuthnInfoDB(app.config['MONGO_URI']) app.support_verification_db = db.SupportVerificationsDB( app.config['MONGO_URI']) app.support_proofing_log_db = db.SupportProofingLogDB( app.config['MONGO_URI']) app.support_dashboard_db = db.SupportDashboardUserDB( app.config['MONGO_URI']) app.support_signup_db = db.SupportSignupUserDB(app.config['MONGO_URI']) app.support_actions_db = db.SupportActionsDB(app.config['MONGO_URI']) app.support_letter_proofing_db = db.SupportLetterProofingDB( app.config['MONGO_URI']) register_template_funcs(app) app.logger.info('Init {} app...'.format(name)) return app
def support_init_app(name, config): """ Create an instance of an eduid support app. First, it will load the configuration from support.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. :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) if app.config.get('TOKEN_SERVICE_URL_LOGOUT') is None: app.config['TOKEN_SERVICE_URL_LOGOUT'] = urlappend(app.config['TOKEN_SERVICE_URL'], 'logout') from eduid_webapp.support.views import support_views app.register_blueprint(support_views) app.support_user_db = db.SupportUserDB(app.config['MONGO_URI']) app.support_authn_db = db.SupportAuthnInfoDB(app.config['MONGO_URI']) app.support_proofing_log_db = db.SupportProofingLogDB(app.config['MONGO_URI']) app.support_signup_db = db.SupportSignupUserDB(app.config['MONGO_URI']) app.support_actions_db = db.SupportActionsDB(app.config['MONGO_URI']) app.support_letter_proofing_db = db.SupportLetterProofingDB(app.config['MONGO_URI']) app.support_oidc_proofing_db = db.SupportOidcProofingDB(app.config['MONGO_URI']) app.support_email_proofing_db = db.SupportEmailProofingDB(app.config['MONGO_URI']) app.support_phone_proofing_db = db.SupportPhoneProofingDB(app.config['MONGO_URI']) app = register_template_funcs(app) app.logger.info('Init {} app...'.format(name)) return app
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
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
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
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
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
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
def load_app(self, config): """ Called from the parent class, so we can provide the appropriate flask app for this test case. """ return eduid_init_app('testing', config)