def __init__(self): user_folder = conan_expand_user("~") server_folder = os.path.join(user_folder, '.conan_server') server_config = migrate_and_get_server_config(user_folder) custom_auth = server_config.custom_authenticator if custom_auth: authenticator = load_authentication_plugin(server_folder, custom_auth) else: authenticator = BasicAuthenticator(dict(server_config.users)) authorizer = BasicAuthorizer(server_config.read_permissions, server_config.write_permissions) credentials_manager = JWTCredentialsManager(server_config.jwt_secret, server_config.jwt_expire_time) updown_auth_manager = JWTUpDownAuthManager(server_config.updown_secret, server_config.authorize_timeout) server_store = get_server_store(server_config.disk_storage_path, server_config.public_url, updown_auth_manager=updown_auth_manager) server_capabilities = SERVER_CAPABILITIES server_capabilities.append(REVISIONS) self.ra = ConanServer(server_config.port, credentials_manager, updown_auth_manager, authorizer, authenticator, server_store, Version(SERVER_VERSION), Version(MIN_CLIENT_COMPATIBLE_VERSION), server_capabilities, only_v1=False)
def __init__(self): user_folder = conan_expand_user("~") server_folder = os.path.join(user_folder, '.conan_server') server_config = migrate_and_get_server_config(user_folder) custom_auth = server_config.custom_authenticator if custom_auth: authenticator = load_authentication_plugin(server_folder, custom_auth) else: authenticator = BasicAuthenticator(dict(server_config.users)) authorizer = BasicAuthorizer(server_config.read_permissions, server_config.write_permissions) credentials_manager = JWTCredentialsManager( server_config.jwt_secret, server_config.jwt_expire_time) updown_auth_manager = JWTUpDownAuthManager( server_config.updown_secret, server_config.authorize_timeout) file_manager = get_file_manager( server_config, updown_auth_manager=updown_auth_manager) search_adapter = DiskSearchAdapter() search_manager = DiskSearchManager( SimplePaths(server_config.disk_storage_path), search_adapter) server_capabilities = SERVER_CAPABILITIES self.ra = ConanServer(server_config.port, credentials_manager, updown_auth_manager, authorizer, authenticator, file_manager, search_manager, Version(SERVER_VERSION), Version(MIN_CLIENT_COMPATIBLE_VERSION), server_capabilities)
def __init__(self, base_path=None, read_permissions=None, write_permissions=None, users=None, base_url=None, plugins=None, server_version=None, min_client_compatible_version=None, server_capabilities=None): plugins = plugins or [] if not base_path: base_path = temp_folder() if server_capabilities is None: server_capabilities = SERVER_CAPABILITIES # Default enabled if not os.path.exists(base_path): raise Exception("Base path not exist! %s") # Define storage_folder, if not, it will be readed from conf file and pointed to real user home self.storage_folder = os.path.join(base_path, ".conan_server", "data") mkdir(self.storage_folder) server_config = migrate_and_get_server_config(base_path, self.storage_folder) if TestServerLauncher.port == 0: TestServerLauncher.port = server_config.port # Encode and Decode signature for Upload and Download service updown_auth_manager = JWTUpDownAuthManager(server_config.updown_secret, server_config.authorize_timeout) self.file_manager = get_file_manager(server_config, public_url=base_url, updown_auth_manager=updown_auth_manager) self.search_manager = DiskSearchManager(SimplePaths(server_config.disk_storage_path)) # Prepare some test users if not read_permissions: read_permissions = server_config.read_permissions read_permissions.append(("private_library/1.0.0@private_user/testing", "*")) read_permissions.append(("*/*@*/*", "*")) if not write_permissions: write_permissions = server_config.write_permissions if not users: users = dict(server_config.users) users[TESTING_REMOTE_PRIVATE_USER] = TESTING_REMOTE_PRIVATE_PASS authorizer = BasicAuthorizer(read_permissions, write_permissions) authenticator = BasicAuthenticator(users) credentials_manager = JWTCredentialsManager(server_config.jwt_secret, server_config.jwt_expire_time) logger.debug("Storage path: %s" % self.storage_folder) self.port = TestServerLauncher.port self.ra = ConanServer(self.port, credentials_manager, updown_auth_manager, authorizer, authenticator, self.file_manager, self.search_manager, server_version, min_client_compatible_version, server_capabilities) for plugin in plugins: self.ra.api_v1.install(plugin)
def __init__(self): user_folder = conan_expand_user("~") server_config = migrate_and_get_server_config(user_folder) authorizer = BasicAuthorizer(server_config.read_permissions, server_config.write_permissions) authenticator = BasicAuthenticator(dict(server_config.users)) credentials_manager = JWTCredentialsManager( server_config.jwt_secret, server_config.jwt_expire_time) updown_auth_manager = JWTUpDownAuthManager( server_config.updown_secret, server_config.authorize_timeout) file_manager = get_file_manager( server_config, updown_auth_manager=updown_auth_manager) search_adapter = DiskSearchAdapter() search_manager = DiskSearchManager( SimplePaths(server_config.disk_storage_path), search_adapter) self.ra = ConanServer(server_config.port, server_config.ssl_enabled, credentials_manager, updown_auth_manager, authorizer, authenticator, file_manager, search_manager, Version(SERVER_VERSION), Version(MIN_CLIENT_COMPATIBLE_VERSION))
def __init__(self, base_path=None, read_permissions=None, write_permissions=None, users=None, base_url=None, plugins=None, server_capabilities=None): plugins = plugins or [] if not base_path: base_path = temp_folder() if not os.path.exists(base_path): raise Exception("Base path not exist! %s") self._base_path = base_path server_config = migrate_and_get_server_config(base_path) if server_capabilities is None: server_capabilities = set(SERVER_CAPABILITIES) if TestServerLauncher.port == 0: TestServerLauncher.port = server_config.port # Encode and Decode signature for Upload and Download service updown_auth_manager = JWTUpDownAuthManager( server_config.updown_secret, server_config.authorize_timeout) base_url = base_url or server_config.public_url self.server_store = get_server_store(server_config.disk_storage_path, base_url, updown_auth_manager) # Prepare some test users if not read_permissions: read_permissions = server_config.read_permissions read_permissions.append( ("private_library/1.0.0@private_user/testing", "*")) read_permissions.append(("*/*@*/*", "*")) if not write_permissions: write_permissions = server_config.write_permissions if not users: users = dict(server_config.users) users[TESTING_REMOTE_PRIVATE_USER] = TESTING_REMOTE_PRIVATE_PASS authorizer = BasicAuthorizer(read_permissions, write_permissions) authenticator = BasicAuthenticator(users) credentials_manager = JWTCredentialsManager( server_config.jwt_secret, server_config.jwt_expire_time) self.port = TestServerLauncher.port self.ra = ConanServer(self.port, credentials_manager, updown_auth_manager, authorizer, authenticator, self.server_store, server_capabilities) for plugin in plugins: self.ra.api_v1.install(plugin) self.ra.api_v2.install(plugin)
def __init__(self, force_migration=False, server_dir=None): if sys.version_info.major == 2: raise Exception("The conan_server needs Python>=3 for running") self.force_migration = force_migration if server_dir: user_folder = server_folder = server_dir else: user_folder = conan_expand_user("~") server_folder = os.path.join(user_folder, '.conan_server') server_config = migrate_and_get_server_config(user_folder, self.force_migration, server_dir is not None) custom_auth = server_config.custom_authenticator if custom_auth: authenticator = load_authentication_plugin(server_folder, custom_auth) else: authenticator = BasicAuthenticator(dict(server_config.users)) authorizer = BasicAuthorizer(server_config.read_permissions, server_config.write_permissions) credentials_manager = JWTCredentialsManager( server_config.jwt_secret, server_config.jwt_expire_time) updown_auth_manager = JWTUpDownAuthManager( server_config.updown_secret, server_config.authorize_timeout) server_store = get_server_store( server_config.disk_storage_path, server_config.public_url, updown_auth_manager=updown_auth_manager) server_capabilities = SERVER_CAPABILITIES server_capabilities.append(REVISIONS) self.server = ConanServer(server_config.port, credentials_manager, updown_auth_manager, authorizer, authenticator, server_store, server_capabilities) if not self.force_migration: print("***********************") print("Using config: %s" % server_config.config_filename) print("Storage: %s" % server_config.disk_storage_path) print("Public URL: %s" % server_config.public_url) print("PORT: %s" % server_config.port) print("***********************")
def __init__(self, force_migration=False): self.force_migration = force_migration user_folder = conan_expand_user("~") server_folder = os.path.join(user_folder, '.conan_server') server_config = migrate_and_get_server_config(user_folder, None, self.force_migration) custom_auth = server_config.custom_authenticator if custom_auth: authenticator = load_authentication_plugin(server_folder, custom_auth) else: authenticator = BasicAuthenticator(dict(server_config.users)) authorizer = BasicAuthorizer(server_config.read_permissions, server_config.write_permissions) credentials_manager = JWTCredentialsManager( server_config.jwt_secret, server_config.jwt_expire_time) updown_auth_manager = JWTUpDownAuthManager( server_config.updown_secret, server_config.authorize_timeout) server_store = get_server_store( server_config.disk_storage_path, server_config.public_url, updown_auth_manager=updown_auth_manager) server_capabilities = SERVER_CAPABILITIES server_capabilities.append(REVISIONS) self.server = ConanServer(server_config.port, credentials_manager, updown_auth_manager, authorizer, authenticator, server_store, Version(SERVER_VERSION), Version(MIN_CLIENT_COMPATIBLE_VERSION), server_capabilities) if not self.force_migration: print("***********************") print("Using config: %s" % server_config.config_filename) print("Storage: %s" % server_config.disk_storage_path) print("Public URL: %s" % server_config.public_url) print("PORT: %s" % server_config.port) print("***********************")