예제 #1
0
def _create_roles(authorization_file_path):
    with open(authorization_file_path) as f:
        roles = load(f)['roles']
    for role in roles:
        user_datastore.find_or_create_role(name=role['name'])
    # return the first role, which is the strongest
    return user_datastore.find_role(roles[0]['name'])
예제 #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()
        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)
예제 #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()

        # 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)
def _create_roles(authorization_file_path):
    with open(authorization_file_path) as f:
        roles = load(f)['roles']
    for role in roles:
        user_datastore.find_or_create_role(name=role['name'])
    # return the first role, which is the strongest
    return user_datastore.find_role(roles[0]['name'])
예제 #5
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)
예제 #6
0
def _create_roles():
    for role in constants.ALL_ROLES:
        user_datastore.find_or_create_role(name=role)
    return user_datastore.find_role(constants.ADMIN_ROLE)