Esempio n. 1
0
    def __init__(self, load_config=True):
        _detect_debug_environment()
        super(CloudifyFlaskApp, self).__init__(__name__)
        if load_config:
            config.instance.load_configuration()
        self._set_sql_alchemy()
        if load_config:
            with self.app_context():
                config.instance.load_from_db()

        # These two need to be called after the configuration was loaded
        setup_logger(self.logger)
        if premium_enabled:
            self.external_auth = configure_auth(self.logger)
        else:
            self.external_auth = None

        self.before_request(log_request)
        self.before_request(maintenance_mode_handler)
        self.after_request(log_response)

        self._set_exception_handlers()
        self._set_flask_security()

        with self.app_context():
            roles = config.instance.authorization_roles
            if roles:
                for role in roles:
                    user_datastore.find_or_create_role(name=role['name'])
                user_datastore.commit()

        setup_resources(Api(self))
        self.register_blueprint(app_errors)
Esempio n. 2
0
    def __init__(self, load_config=True):
        _detect_debug_environment()
        super(CloudifyFlaskApp, self).__init__(__name__)
        if load_config:
            config.instance.load_configuration()
        self._set_sql_alchemy()

        # This must be the first before_request, otherwise db access may break
        # after db failovers or db proxy restarts
        self.before_request(cope_with_db_failover)

        # These two need to be called after the configuration was loaded
        if config.instance.rest_service_log_path:
            setup_logger(self.logger)
        if premium_enabled and config.instance.file_server_root:
            self.external_auth = configure_auth(self.logger)
            self.before_request(LicenseHandler.check_license_expiration_date)
        else:
            self.external_auth = None

        self.before_request(log_request)
        self.before_request(maintenance_mode_handler)
        self.after_request(log_response)
        self._set_flask_security()

        with self.app_context():
            roles = config.instance.authorization_roles
            if roles:
                for role in roles:
                    user_datastore.find_or_create_role(name=role['name'])
                user_datastore.commit()

        with self._prevent_flask_restful_error_handling():
            setup_resources(Api(self))
        self.register_blueprint(app_errors)
Esempio n. 3
0
    def __init__(self, load_config=True):
        _detect_debug_environment()
        super(CloudifyFlaskApp, self).__init__(__name__)
        if load_config:
            config.instance.load_configuration()
        self._set_sql_alchemy()
        # These two need to be called after the configuration was loaded
        if config.instance.rest_service_log_path:
            setup_logger(self.logger)
        if premium_enabled and config.instance.file_server_root:
            self.external_auth = configure_auth(self.logger)
            self.before_request(LicenseHandler.check_license_expiration_date)
        else:
            self.external_auth = None

        self.before_request(log_request)
        self.before_request(maintenance_mode_handler)
        self.after_request(log_response)
        self._set_exception_handlers()
        self._set_flask_security()

        with self.app_context():
            roles = config.instance.authorization_roles
            if roles:
                for role in roles:
                    user_datastore.find_or_create_role(name=role['name'])
                user_datastore.commit()

        setup_resources(Api(self))
        self.register_blueprint(app_errors)
Esempio n. 4
0
    def __init__(self, load_config=True):
        _detect_debug_environment()
        super(CloudifyFlaskApp, self).__init__(__name__)
        if load_config:
            config.instance.load_configuration()

        # These two need to be called after the configuration was loaded
        setup_logger(self.logger)
        self.premium_enabled = premium_enabled
        if self.premium_enabled:
            self.ldap = configure_ldap()
            self.okta = configure_okta()
        else:
            self.ldap = None
            self.okta = None

        self.before_request(log_request)
        self.before_request(maintenance_mode_handler)
        self.after_request(log_response)

        self._set_exception_handlers()
        self._set_sql_alchemy()
        self._set_flask_security()

        setup_resources(Api(self))
Esempio n. 5
0
    def __init__(self, load_config=True):
        _detect_debug_environment()
        super(CloudifyFlaskApp, self).__init__(__name__)
        if load_config:
            config.instance.load_configuration()

        # These two need to be called after the configuration was loaded
        setup_logger(self.logger, 'manager_rest')
        configure_ldap()

        self.before_request(log_request)
        self.before_request(maintenance_mode_handler)
        self.after_request(log_response)

        self._set_exception_handlers()
        self._set_sql_alchemy()
        self._set_flask_security()

        self.app_context().push()  # Set the app's context globally
        setup_resources(Api(self))