Apache Solr open-source search software
SOLR-17584: Remove code and docs for "trusted" configsets (#3272)
Abhishek Umarjikara93c09164dce
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex e1fd5d1eebb..18d0253172e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -164,6 +164,10 @@ Other Changes* SOLR-17706: SolrJ DocumentObjectBinder is now a global singleton via an INSTANCE field and thatwhich is pluggable via Java SPI/ServiceLoader. SolrClient.getBinder is gone. (David Smiley)+* SOLR-17584: There is no longer a distinction between trusted and untrusted configSets; all are now trusted.+ To ensure security, Solr should enforce authentication and authorization,+ allowing only authorized admins to publish them. (Abhishek Umarjikar)+================== 9.9.0 ==================New Features---------------------diff --git a/solr/core/src/java/org/apache/solr/cli/CreateTool.java b/solr/core/src/java/org/apache/solr/cli/CreateTool.javaindex b4d5f2ef846..12ed4f76711 100644--- a/solr/core/src/java/org/apache/solr/cli/CreateTool.java+++ b/solr/core/src/java/org/apache/solr/cli/CreateTool.java@@ -283,7 +283,7 @@ public class CreateTool extends ToolBase {+ " to ZooKeeper at "+ cloudSolrClient.getClusterStateProvider().getQuorumHosts());// We will trust the config since we have the Zookeeper Address- configSetService.uploadConfig(confName, confPath, true);+ configSetService.uploadConfig(confName, confPath);}// since creating a collection is a heavy-weight operation, check for existence firstdiff --git a/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java b/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.javaindex a0b53ea88e8..44638776bf3 100644--- a/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java+++ b/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java@@ -167,7 +167,7 @@ public class ZkConfigSetService extends ConfigSetService {}@Override- protected void uploadConfig(String configName, Path dir) throws IOException {+ public void uploadConfig(String configName, Path dir) throws IOException {zkClient.uploadToZK(dir, CONFIGS_ZKNODE + "/" + configName, ConfigSetService.UPLOAD_FILENAME_EXCLUDE_PATTERN);}diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.javaindex 9a4b99514d0..55d1725e6ec 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java@@ -150,7 +150,6 @@ public class RestoreCmd implements CollApiCmds.CollectionApiCommand {final URI location;final URI backupPath;final List<String> nodeList;- final boolean requestIsTrusted;final CoreContainer container;final BackupRepository repository;@@ -166,7 +165,6 @@ public class RestoreCmd implements CollApiCmds.CollectionApiCommand {this.asyncId = message.getStr(ASYNC);this.repo = message.getStr(CoreAdminParams.BACKUP_REPOSITORY);this.backupId = message.getInt(CoreAdminParams.BACKUP_ID, -1);- this.requestIsTrusted = message.getBool(CoreAdminParams.TRUSTED, false);this.container = ccc.getCoreContainer();this.repository = this.container.newBackupRepository(repo);@@ -230,8 +228,7 @@ public class RestoreCmd implements CollApiCmds.CollectionApiCommand {rc.backupProperties.getConfigName(),rc.restoreConfigName,rc.backupManager,- rc.container.getConfigSetService(),- rc.requestIsTrusted);+ rc.container.getConfigSetService());log.info("Starting restore into collection={} with backup_name={} at location={}",@@ -296,8 +293,7 @@ public class RestoreCmd implements CollApiCmds.CollectionApiCommand {String configName,String restoreConfigName,BackupManager backupMgr,- ConfigSetService configSetService,- boolean requestIsTrusted)+ ConfigSetService configSetService)throws IOException {if (configSetService.checkConfigExists(restoreConfigName)) {log.info(@@ -309,8 +305,7 @@ public class RestoreCmd implements CollApiCmds.CollectionApiCommand {"Config with name {} does not already exist in ZooKeeper. Will restore from Backup.",restoreConfigName);- backupMgr.uploadConfigDir(- configName, restoreConfigName, configSetService, requestIsTrusted);+ backupMgr.uploadConfigDir(configName, restoreConfigName, configSetService);}}diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSet.java b/solr/core/src/java/org/apache/solr/core/ConfigSet.javaindex de363f69d90..c64e86ddfef 100644--- a/solr/core/src/java/org/apache/solr/core/ConfigSet.java+++ b/solr/core/src/java/org/apache/solr/core/ConfigSet.java@@ -35,20 +35,16 @@ public class ConfigSet {private final NamedList<?> properties;- private final boolean trusted;-public ConfigSet(String name,SolrConfig solrConfig,SchemaSupplier indexSchemaSupplier,- NamedList<?> properties,- boolean trusted) {+ NamedList<?> properties) {this.name = name;this.solrConfig = solrConfig;this.schemaSupplier = indexSchemaSupplier;schema = schemaSupplier.get(true);this.properties = properties;- this.trusted = trusted;}public String getName() {@@ -75,10 +71,6 @@ public class ConfigSet {return properties;}- public boolean isTrusted() {- return trusted;- }-/*** Provide a Schema object on demand We want IndexSchema Objects to be lazily instantiated because* when a configset is created the {@link SolrResourceLoader} associated with it is not associateddiff --git a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java b/solr/core/src/java/org/apache/solr/core/ConfigSetService.javaindex a9f9b417abf..bffce6483de 100644--- a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java+++ b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java@@ -23,7 +23,6 @@ import java.lang.invoke.MethodHandles;import java.lang.reflect.Constructor;import java.nio.file.Files;import java.nio.file.Path;-import java.util.HashMap;import java.util.List;import java.util.Locale;import java.util.Map;@@ -117,7 +116,7 @@ public abstract class ConfigSetService {"intended to be the default. Current 'solr.default.confdir' value:",System.getProperty(SolrDispatchFilter.SOLR_DEFAULT_CONFDIR_ATTRIBUTE));} else {- this.uploadConfig(ConfigSetsHandler.DEFAULT_CONFIGSET_NAME, configDirPath, true);+ this.uploadConfig(ConfigSetsHandler.DEFAULT_CONFIGSET_NAME, configDirPath);}}}@@ -132,7 +131,7 @@ public abstract class ConfigSetService {String confName =System.getProperty(ZkController.COLLECTION_PARAM_PREFIX + ZkController.CONFIGNAME_PROP, "configuration1");- this.uploadConfig(confName, configPath, true);+ this.uploadConfig(confName, configPath);}/**@@ -216,47 +215,10 @@ public abstract class ConfigSetService {if (StrUtils.isNullOrEmpty(confName)) confName = coreName;Path udir = cd.getInstanceDir().resolve("conf");log.info("Uploading directory {} with name {} for solrCore {}", udir, confName, coreName);- cc.getConfigSetService().uploadConfig(confName, udir, true);+ cc.getConfigSetService().uploadConfig(confName, udir);}}- /**- * Return whether the given configSet is trusted.- *- * @param name name of the configSet- */- public boolean isConfigSetTrusted(String name) throws IOException {- Map<String, Object> contentMap = getConfigMetadata(name);- return (boolean) contentMap.getOrDefault("trusted", true);- }-- /**- * Return whether the configSet used for the given resourceLoader is trusted.- *- * @param coreLoader resourceLoader for a core- */- public boolean isConfigSetTrusted(SolrResourceLoader coreLoader) throws IOException {- // ConfigSet flags are loaded from the metadata of the ZK node of the configset. (For the- // ZKConfigSetService)- NamedList<?> flags = loadConfigSetFlags(coreLoader);-- // Trust if there is no trusted flag (i.e. the ConfigSetApi was not used for this configSet)- // or if the trusted flag is set to "true".- return (flags == null || flags.get("trusted") == null || flags.getBooleanArg("trusted"));- }-- /**- * Change the trust of the given configSet.- *- * @param name name of the configSet- * @param isTrusted whether the given configSet should be trusted or not- */- public void setConfigSetTrust(String name, boolean isTrusted) throws IOException {- Map<String, Object> contentMap = new HashMap<>(getConfigMetadata(name));- contentMap.put("trusted", isTrusted);- setConfigMetadata(name, contentMap);- }-/*** Load the ConfigSet for a core*@@ -270,7 +232,6 @@ public abstract class ConfigSetService {try {// ConfigSet properties are loaded from ConfigSetProperties.DEFAULT_FILENAME file.NamedList<?> properties = loadConfigSetProperties(dcore, coreLoader);- boolean trusted = isConfigSetTrusted(coreLoader);SolrConfig solrConfig = createSolrConfig(dcore, coreLoader);return new ConfigSet(@@ -283,8 +244,7 @@ public abstract class ConfigSetService {throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e.getMessage(), e);}},- properties,- trusted);+ properties);} catch (Exception e) {throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,@@ -418,20 +378,7 @@ public abstract class ConfigSetService {* @param dir {@link Path} to the files* @throws IOException if an I/O error occurs or the path does not exist*/- protected abstract void uploadConfig(String configName, Path dir) throws IOException;-- /**- * Upload files from a given path to config, which will explicitly be trusted or not.- *- * @param configName the config name- * @param dir {@link Path} to the files- * @param isTrusted whether the config being uploaded is trusted- * @throws IOException if an I/O error occurs or the path does not exist- */- public void uploadConfig(String configName, Path dir, boolean isTrusted) throws IOException {- setConfigSetTrust(configName, isTrusted);- uploadConfig(configName, dir);- }+ public abstract void uploadConfig(String configName, Path dir) throws IOException;/*** Upload a file to config If file does not exist, it will be uploaded If overwriteOnExists is set@@ -507,22 +454,6 @@ public abstract class ConfigSetService {protected abstract void setConfigMetadata(String configName, Map<String, Object> data)throws IOException;- /**- * Set the config metadata If config does not exist, it will be created and set metadata on it- * Else metadata will be replaced with the provided metadata. This will preserve the trust that- * the configSet already has if trust is not included in the metadata.- *- * @param configName the config name- * @param data the metadata to be set on config- */- public void setConfigMetadataWithTrust(String configName, Map<String, Object> data)- throws IOException {- if (!data.containsKey("trusted")) {- data.put("trusted", isConfigSetTrusted(configName));- }- setConfigMetadata(configName, data);- }-/*** Get the config metadata (mutable, non-null)*diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.javaindex c3018ab108c..7462914e5b6 100644--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java@@ -1741,13 +1741,11 @@ public class CoreContainer {}ConfigSet coreConfig = coreConfigService.loadConfigSet(dcore);- dcore.setConfigSetTrusted(coreConfig.isTrusted());if (log.isInfoEnabled()) {log.info(- "Creating SolrCore '{}' using configuration from {}, trusted={}",+ "Creating SolrCore '{}' using configuration from {}",dcore.getName(),- coreConfig.getName(),- dcore.isConfigSetTrusted());+ coreConfig.getName());}try {core = new SolrCore(this, dcore, coreConfig);diff --git a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.javaindex 27d91b4d90e..87599b711d8 100644--- a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java+++ b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java@@ -66,13 +66,6 @@ public class CoreDescriptor {public static final String DEFAULT_EXTERNAL_PROPERTIES_FILE ="conf" + FileSystems.getDefault().getSeparator() + "solrcore.properties";- /**- * Whether this core was configured using a configSet that was trusted. This helps in avoiding the- * loading of plugins that have potential vulnerabilities, when the configSet was not uploaded- * from a trusted user.- */- private boolean trustedConfigSet = true;-/*** Get the standard properties in persistable form*@@ -174,7 +167,6 @@ public class CoreDescriptor {this.coreProperties.setProperty(CORE_NAME, coreName);this.originalCoreProperties.setProperty(CORE_NAME, coreName);this.substitutableProperties.setProperty(SOLR_CORE_PROP_PREFIX + CORE_NAME, coreName);- this.trustedConfigSet = other.trustedConfigSet;}/**@@ -396,13 +388,4 @@ public class CoreDescriptor {public String getConfigSetPropertiesName() {return coreProperties.getProperty(CORE_CONFIGSET_PROPERTIES);}-- public boolean isConfigSetTrusted() {- return trustedConfigSet;- }-- /** TODO remove mutability */- public void setConfigSetTrusted(boolean trusted) {- this.trustedConfigSet = trusted;- }}diff --git a/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java b/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.javaindex 56f17c395d1..c904035983a 100644--- a/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java+++ b/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java@@ -140,7 +140,7 @@ public class FileSystemConfigSetService extends ConfigSetService {}@Override- protected void uploadConfig(String configName, Path source) throws IOException {+ public void uploadConfig(String configName, Path source) throws IOException {Path dest = getConfigDir(configName);copyRecursively(source, dest);}diff --git a/solr/core/src/java/org/apache/solr/core/SyntheticSolrCore.java b/solr/core/src/java/org/apache/solr/core/SyntheticSolrCore.javaindex f521dbb2c20..7e67a7b7ac9 100644--- a/solr/core/src/java/org/apache/solr/core/SyntheticSolrCore.java+++ b/solr/core/src/java/org/apache/solr/core/SyntheticSolrCore.java@@ -64,7 +64,6 @@ public class SyntheticSolrCore extends SolrCore {syntheticCoreDescriptor.setConfigSet(configSetName);ConfigSet coreConfig =coreContainer.getConfigSetService().loadConfigSet(syntheticCoreDescriptor);- syntheticCoreDescriptor.setConfigSetTrusted(coreConfig.isTrusted());SyntheticSolrCore syntheticCore =new SyntheticSolrCore(coreContainer, syntheticCoreDescriptor, coreConfig);coreContainer.registerCore(syntheticCoreDescriptor, syntheticCore, false, false);diff --git a/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java b/solr/core/src/java/org/apache/solr/core/backup/BackupManager.javaindex 37a18e08243..20f3bc3e26d 100644--- a/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java+++ b/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java@@ -255,16 +255,12 @@ public class BackupManager {* @throws IOException in case of I/O errors.*/public void uploadConfigDir(- String sourceConfigName,- String targetConfigName,- ConfigSetService configSetService,- boolean requestIsTrusted)+ String sourceConfigName, String targetConfigName, ConfigSetService configSetService)throws IOException {URI source = repository.resolveDirectory(getZkStateDir(), CONFIG_STATE_DIR, sourceConfigName);if (!repository.exists(source)) {throw new IllegalArgumentException("Configset expected at " + source + " does not exist");}- configSetService.setConfigSetTrust(targetConfigName, requestIsTrusted);uploadConfigToSolrCloud(configSetService, source, targetConfigName, "");}diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCollection.java b/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCollection.javaindex 6d2a9eb25a3..12da6f005f8 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCollection.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCollection.java@@ -29,7 +29,6 @@ import static org.apache.solr.common.params.CommonParams.NAME;import static org.apache.solr.common.params.CoreAdminParams.BACKUP_ID;import static org.apache.solr.common.params.CoreAdminParams.BACKUP_LOCATION;import static org.apache.solr.common.params.CoreAdminParams.BACKUP_REPOSITORY;-import static org.apache.solr.common.params.CoreAdminParams.TRUSTED;import static org.apache.solr.handler.admin.CollectionsHandler.DEFAULT_COLLECTION_OP_TIMEOUT;import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PERM;@@ -52,7 +51,6 @@ import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.util.Utils;import org.apache.solr.core.CoreContainer;import org.apache.solr.handler.admin.CollectionsHandler;-import org.apache.solr.handler.configsets.ConfigSetAPIBase;import org.apache.solr.jersey.PermissionName;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.response.SolrQueryResponse;@@ -168,10 +166,6 @@ public class RestoreCollection extends BackupAPIBase implements CollectionBackup// Copy restore-specific parametersremoteMessage.put(QUEUE_OPERATION, CollectionParams.CollectionAction.RESTORE.toLower());remoteMessage.put(NAME, backupName);- remoteMessage.put(- TRUSTED,- ConfigSetAPIBase.isTrusted(- solrQueryRequest.getUserPrincipal(), coreContainer.getAuthenticationPlugin()));return new ZkNodeProps(remoteMessage);}diff --git a/solr/core/src/java/org/apache/solr/handler/configsets/CloneConfigSet.java b/solr/core/src/java/org/apache/solr/handler/configsets/CloneConfigSet.javaindex e55c74e04fa..c98442d8b44 100644--- a/solr/core/src/java/org/apache/solr/handler/configsets/CloneConfigSet.java+++ b/solr/core/src/java/org/apache/solr/handler/configsets/CloneConfigSet.java@@ -18,7 +18,6 @@package org.apache.solr.handler.configsets;import static org.apache.solr.common.params.CommonParams.NAME;-import static org.apache.solr.handler.admin.ConfigSetsHandler.DISABLE_CREATE_AUTH_CHECKS;import static org.apache.solr.security.PermissionNameProvider.Name.CONFIG_EDIT_PERM;import jakarta.inject.Inject;@@ -63,15 +62,6 @@ public class CloneConfigSet extends ConfigSetAPIBase implements ConfigsetsApi.Cl"Base ConfigSet does not exist: " + requestBody.baseConfigSet);}- if (!DISABLE_CREATE_AUTH_CHECKS- && !isTrusted(solrQueryRequest.getUserPrincipal(), coreContainer.getAuthenticationPlugin())- && configSetService.isConfigSetTrusted(requestBody.baseConfigSet)) {- throw new SolrException(- SolrException.ErrorCode.UNAUTHORIZED,- "Can't create a configset with an unauthenticated request from a trusted "- + ConfigSetCmds.BASE_CONFIGSET);- }-final Map<String, Object> configsetCommandMsg = new HashMap<>();configsetCommandMsg.put(NAME, requestBody.name);configsetCommandMsg.put(ConfigSetCmds.BASE_CONFIGSET, requestBody.baseConfigSet);diff --git a/solr/core/src/java/org/apache/solr/handler/configsets/ConfigSetAPIBase.java b/solr/core/src/java/org/apache/solr/handler/configsets/ConfigSetAPIBase.javaindex f6e99167f30..503917da584 100644--- a/solr/core/src/java/org/apache/solr/handler/configsets/ConfigSetAPIBase.java+++ b/solr/core/src/java/org/apache/solr/handler/configsets/ConfigSetAPIBase.java@@ -23,7 +23,6 @@ import static org.apache.solr.handler.admin.ConfigSetsHandler.CONFIG_SET_TIMEOUTimport java.io.IOException;import java.io.InputStream;import java.lang.invoke.MethodHandles;-import java.security.Principal;import java.util.Iterator;import java.util.Map;import java.util.Optional;@@ -43,7 +42,6 @@ import org.apache.solr.core.ConfigSetService;import org.apache.solr.core.CoreContainer;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.response.SolrQueryResponse;-import org.apache.solr.security.AuthenticationPlugin;import org.apache.zookeeper.KeeperException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -117,15 +115,6 @@ public class ConfigSetAPIBase extends JerseyResource {return contentStreamsIterator.next().getStream();}- public static boolean isTrusted(Principal userPrincipal, AuthenticationPlugin authPlugin) {- if (authPlugin != null && userPrincipal != null) {- log.debug("Trusted configset request");- return true;- }- log.debug("Untrusted configset request");- return false;- }-protected void createBaseNode(ConfigSetService configSetService,boolean overwritesExisting,@@ -134,24 +123,9 @@ public class ConfigSetAPIBase extends JerseyResource {throws IOException {if (overwritesExisting) {if (!requestIsTrusted) {- ensureOverwritingUntrustedConfigSet(configName);+ throw new SolrException(+ SolrException.ErrorCode.BAD_REQUEST, "Trying to make an untrusted ConfigSet update");}- // If the request is trusted and cleanup=true, then the configSet will be set to trusted after- // the overwriting has been done.- } else {- configSetService.setConfigSetTrust(configName, requestIsTrusted);- }- }-- /*- * Fail if an untrusted request tries to update a trusted ConfigSet- */- private void ensureOverwritingUntrustedConfigSet(String configName) throws IOException {- boolean isCurrentlyTrusted = configSetService.isConfigSetTrusted(configName);- if (isCurrentlyTrusted) {- throw new SolrException(- SolrException.ErrorCode.BAD_REQUEST,- "Trying to make an untrusted ConfigSet update on a trusted configSet");}}diff --git a/solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java b/solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.javaindex d42adf94999..555adb1acaa 100644--- a/solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java+++ b/solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java@@ -61,8 +61,6 @@ public class UploadConfigSet extends ConfigSetAPIBase implements ConfigsetsApi.UensureConfigSetUploadEnabled();boolean overwritesExisting = configSetService.checkConfigExists(configSetName);- boolean requestIsTrusted =- isTrusted(solrQueryRequest.getUserPrincipal(), coreContainer.getAuthenticationPlugin());// Get upload parametersif (overwrite == null) overwrite = true;if (cleanup == null) cleanup = false;@@ -80,11 +78,6 @@ public class UploadConfigSet extends ConfigSetAPIBase implements ConfigsetsApi.UfilesToDelete = Collections.emptyList();}- // Create a node for the configuration in zookeeper- // For creating the baseZnode, the cleanup parameter is only allowed to be true when- // singleFilePath is not passed.- createBaseNode(configSetService, overwritesExisting, requestIsTrusted, configSetName);-try (ZipInputStream zis = new ZipInputStream(requestBody, StandardCharsets.UTF_8)) {boolean hasEntry = false;ZipEntry zipEntry;@@ -104,14 +97,6 @@ public class UploadConfigSet extends ConfigSetAPIBase implements ConfigsetsApi.U}deleteUnusedFiles(configSetService, configSetName, filesToDelete);- // If the request is doing a full trusted overwrite of an untrusted configSet (overwrite=true,- // cleanup=true), then trust the configSet.- if (cleanup- && requestIsTrusted- && overwritesExisting- && !configSetService.isConfigSetTrusted(configSetName)) {- configSetService.setConfigSetTrust(configSetName, true);- }return response;}@@ -128,8 +113,6 @@ public class UploadConfigSet extends ConfigSetAPIBase implements ConfigsetsApi.UensureConfigSetUploadEnabled();boolean overwritesExisting = configSetService.checkConfigExists(configSetName);- boolean requestIsTrusted =- isTrusted(solrQueryRequest.getUserPrincipal(), coreContainer.getAuthenticationPlugin());// Get upload parameters@@ -162,7 +145,6 @@ public class UploadConfigSet extends ConfigSetAPIBase implements ConfigsetsApi.U// Create a node for the configuration in config// For creating the baseNode, the cleanup parameter is only allowed to be true when// singleFilePath is not passed.- createBaseNode(configSetService, overwritesExisting, requestIsTrusted, configSetName);configSetService.uploadFileToConfig(configSetName, fixedSingleFilePath, data, overwrite);}return response;diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.javaindex 9973721ac48..29b93142ec8 100644--- a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java+++ b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java@@ -71,7 +71,6 @@ import org.apache.solr.common.util.StrUtils;import org.apache.solr.core.CoreContainer;import org.apache.solr.core.SolrConfig;import org.apache.solr.core.SolrResourceLoader;-import org.apache.solr.handler.configsets.ConfigSetAPIBase;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.response.RawResponseWriter;import org.apache.solr.response.SolrQueryResponse;@@ -245,8 +244,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {data = in.readAllBytes();}Exception updateFileError = null;- boolean requestIsTrusted =- ConfigSetAPIBase.isTrusted(req.getUserPrincipal(), coreContainer.getAuthenticationPlugin());+if (SOLR_CONFIG_XML.equals(file)) {// verify the updated solrconfig.xml is valid before saving to ZK (to avoid things blowing up// later)@@ -278,11 +276,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {throw new IOException("Failed to save data in ZK at path: " + zkPath, SolrZkClient.checkInterrupted(e));}- // If the request is untrusted, and the configSet is trusted, remove the trusted flag on the- // configSet.- if (configSetHelper.isConfigSetTrusted(mutableId) && !requestIsTrusted) {- configSetHelper.removeConfigSetTrust(mutableId);- }configSetHelper.reloadTempCollection(mutableId, false);diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.javaindex 81e4003c29f..53970f9bfed 100644--- a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java+++ b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java@@ -1135,28 +1135,6 @@ class SchemaDesignerConfigSetHelper implements SchemaDesignerConstants {return baos.toByteArray();}- public boolean isConfigSetTrusted(String configSetName) {- try {- return cc.getConfigSetService().isConfigSetTrusted(configSetName);- } catch (IOException e) {- throw new SolrException(- SolrException.ErrorCode.SERVER_ERROR,- "Could not load conf " + configSetName + ": " + e.getMessage(),- e);- }- }-- public void removeConfigSetTrust(String configSetName) {- try {- cc.getConfigSetService().setConfigSetTrust(configSetName, false);- } catch (IOException e) {- throw new SolrException(- SolrException.ErrorCode.SERVER_ERROR,- "Could not remove trusted flag for configSet " + configSetName + ": " + e.getMessage(),- e);- }- }-protected ZkSolrResourceLoader zkLoaderForConfigSet(final String configSet) {SolrResourceLoader loader = cc.getResourceLoader();return new ZkSolrResourceLoader(diff --git a/solr/core/src/test/org/apache/solr/cloud/MockScriptUpdateProcessorFactory.java b/solr/core/src/test/org/apache/solr/cloud/MockScriptUpdateProcessorFactory.javaindex 06e65537468..de6be081bf4 100644--- a/solr/core/src/test/org/apache/solr/cloud/MockScriptUpdateProcessorFactory.java+++ b/solr/core/src/test/org/apache/solr/cloud/MockScriptUpdateProcessorFactory.java@@ -17,16 +17,12 @@package org.apache.solr.cloud;import java.io.IOException;-import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;import org.apache.solr.common.SolrInputDocument;-import org.apache.solr.core.SolrCore;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.response.SolrQueryResponse;import org.apache.solr.update.AddUpdateCommand;import org.apache.solr.update.processor.UpdateRequestProcessor;import org.apache.solr.update.processor.UpdateRequestProcessorFactory;-import org.apache.solr.util.plugin.SolrCoreAware;/*** The scripting update processor capability is something that is only allowed by a trusted@@ -34,19 +30,7 @@ import org.apache.solr.util.plugin.SolrCoreAware;* configsets lives in TestConfigSetsAPI. This class is meant to simulate the* ScriptUpdateProcessorFactory for this test.*/-public class MockScriptUpdateProcessorFactory extends UpdateRequestProcessorFactory- implements SolrCoreAware {-- @Override- public void inform(SolrCore core) {- if (!core.getCoreDescriptor().isConfigSetTrusted()) {- throw new SolrException(- ErrorCode.UNAUTHORIZED,- "The configset for this collection was uploaded without any authentication in place,"- + " and this operation is not available for collections with untrusted configsets. To use this component, re-upload the configset"- + " after enabling authentication and authorization.");- }- }+public class MockScriptUpdateProcessorFactory extends UpdateRequestProcessorFactory {@Overridepublic UpdateRequestProcessor getInstance(diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.javaindex baa659b7e68..ebc331c99d0 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java@@ -146,7 +146,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {public void testCreateErrors() throws Exception {final String baseUrl = cluster.getJettySolrRunners().get(0).getBaseUrl().toString();try (final SolrClient solrClient = getHttpSolrClient(baseUrl)) {- getConfigSetService().uploadConfig("configSet", configset("configset-2"), false);+ getConfigSetService().uploadConfig("configSet", configset("configset-2"));// no actionCreateNoErrorChecking createNoAction = new CreateNoErrorChecking();@@ -202,89 +202,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {"solr");}- @Test- public void testCreateWithTrust() throws Exception {- String configsetName = "regular";- String trustedConfigsetSuffix = "testCreateWithTrustTrusted";- String untrustedConfigsetSuffix = "testCreateWithTrustUntrusted";- uploadConfigSetWithAssertions(configsetName, trustedConfigsetSuffix, "solr");- uploadConfigSetWithAssertions(configsetName, untrustedConfigsetSuffix, null);- try (SolrZkClient zkClient =- new SolrZkClient.Builder()- .withUrl(cluster.getZkServer().getZkAddress())- .withTimeout(AbstractZkTestCase.TIMEOUT, TimeUnit.MILLISECONDS)- .withConnTimeOut(45000, TimeUnit.MILLISECONDS)- .build()) {- assertTrue(isTrusted(zkClient, configsetName, trustedConfigsetSuffix));- assertFalse(isTrusted(zkClient, configsetName, untrustedConfigsetSuffix));- // base trusted -> untrusted- SolrException e =- assertThrows(- SolrException.class,- () ->- createConfigSet(- null, // base is default trusted- "abc",- Collections.emptyMap(),- cluster.getSolrClient(),- null) // without username is untrusted- );- assertEquals(SolrException.ErrorCode.UNAUTHORIZED.code, e.code());- // base trusted -> untrusted- SolrException e2 =- assertThrows(- SolrException.class,- () ->- createConfigSet(- "_default", // base is default trusted- "def",- Collections.emptyMap(),- cluster.getSolrClient(),- null) // without username is untrusted- );- assertEquals(SolrException.ErrorCode.UNAUTHORIZED.code, e2.code());- // trusted -> untrusted- SolrException e3 =- assertThrows(- SolrException.class,- () ->- createConfigSet(- configsetName + trustedConfigsetSuffix,- "foo",- Collections.emptyMap(),- cluster.getSolrClient(),- null) // without username is untrusted- );- assertEquals(SolrException.ErrorCode.UNAUTHORIZED.code, e3.code());- // trusted -> trusted- verifyCreate(- configsetName + trustedConfigsetSuffix,- "foo2",- Collections.emptyMap(),- Collections.emptyMap(),- "solr"); // with username is trusted- assertTrue(isTrusted(zkClient, "foo2", ""));-- // untrusted -> untrusted- verifyCreate(- configsetName + untrustedConfigsetSuffix,- "bar",- Collections.emptyMap(),- Collections.emptyMap(),- null); // without username is untrusted- assertFalse(isTrusted(zkClient, "bar", ""));-- // untrusted -> trusted- verifyCreate(- configsetName + untrustedConfigsetSuffix,- "bar2",- Collections.emptyMap(),- Collections.emptyMap(),- "solr"); // with username is trusted- assertFalse(isTrusted(zkClient, "bar2", ""));- }- }-private void setupBaseConfigSet(String baseConfigSetName, Map<String, String> oldProps)throws Exception {final Path configDir = getFile("solr").resolve("configsets/configset-2/conf");@@ -297,9 +214,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {getConfigSetProps(oldProps),UTF_8);}- getConfigSetService()- .uploadConfig(- baseConfigSetName, tmpConfigDir, isTrusted(zkClient(), baseConfigSetName, ""));+ getConfigSetService().uploadConfig(baseConfigSetName, tmpConfigDir);}private void verifyCreate(@@ -688,126 +603,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {}}- @Test- public void testOverwriteWithTrustV1() throws Exception {- testOverwriteWithTrust(false);- }-- @Test- public void testOverwriteWithTrustV2() throws Exception {- testOverwriteWithTrust(true);- }-- public void testOverwriteWithTrust(boolean v2) throws Exception {- String configsetName = "regular";- String configsetSuffix = "testOverwriteWithTrust-1-" + v2;- uploadConfigSetWithAssertions(configsetName, configsetSuffix, null);- try (SolrZkClient zkClient =- new SolrZkClient.Builder()- .withUrl(cluster.getZkServer().getZkAddress())- .withTimeout(AbstractZkTestCase.TIMEOUT, TimeUnit.MILLISECONDS)- .withConnTimeOut(45000, TimeUnit.MILLISECONDS)- .build()) {- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix));- int solrconfigZkVersion =- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml");- // Was untrusted, overwrite with untrusted- assertEquals(- 0, uploadConfigSet(configsetName, configsetSuffix, null, true, false, v2, false, false));- assertTrue(- "Expecting version bump",- solrconfigZkVersion- < getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml"));- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix));- solrconfigZkVersion =- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml");-- // Was untrusted, overwrite with trusted but no cleanup- assertEquals(- 0,- uploadConfigSet(configsetName, configsetSuffix, "solr", true, false, v2, false, false));- assertTrue(- "Expecting version bump",- solrconfigZkVersion- < getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml"));- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix));- solrconfigZkVersion =- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml");-- // Was untrusted, overwrite with trusted with cleanup but fail on unzipping.- // Should not set trusted=true in configSet- ignoreException(- "Either empty zipped data, or non-zipped data was passed. In order to upload a configSet, you must zip a non-empty directory to upload.");- assertEquals(400, uploadBadConfigSet(configsetName, configsetSuffix, "solr", v2));- assertEquals(- "Expecting version bump",- solrconfigZkVersion,- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml"));- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix));- solrconfigZkVersion =- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml");- ignoreException(- "Either empty zipped data, or non-zipped data was passed. In order to upload a configSet, you must zip a non-empty directory to upload.");-- // Was untrusted, overwrite with trusted with cleanup- assertEquals(- 0, uploadConfigSet(configsetName, configsetSuffix, "solr", true, true, v2, false, false));- assertTrue(- "Expecting version bump",- solrconfigZkVersion- < getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml"));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));- solrconfigZkVersion =- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml");-- // Was trusted, try to overwrite with untrusted with no cleanup- ignoreException("Trying to make an unstrusted ConfigSet update on a trusted configSet");- assertEquals(- "Can't upload a trusted configset with an untrusted request",- 400,- uploadConfigSet(configsetName, configsetSuffix, null, true, false, v2, false, false));- assertEquals(- "Expecting version to remain equal",- solrconfigZkVersion,- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml"));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));-- // Was trusted, try to overwrite with untrusted with cleanup- ignoreException("Trying to make an unstrusted ConfigSet update on a trusted configSet");- assertEquals(- "Can't upload a trusted configset with an untrusted request",- 400,- uploadConfigSet(configsetName, configsetSuffix, null, true, true, v2, false, false));- assertEquals(- "Expecting version to remain equal",- solrconfigZkVersion,- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml"));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));- unIgnoreException("Trying to make an unstrusted ConfigSet update on a trusted configSet");-- // Was trusted, overwrite with trusted no cleanup- assertEquals(- 0,- uploadConfigSet(configsetName, configsetSuffix, "solr", true, false, v2, false, false));- assertTrue(- "Expecting version bump",- solrconfigZkVersion- < getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml"));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));- solrconfigZkVersion =- getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml");-- // Was trusted, overwrite with trusted with cleanup- assertEquals(- 0, uploadConfigSet(configsetName, configsetSuffix, "solr", true, true, v2, false, false));- assertTrue(- "Expecting version bump",- solrconfigZkVersion- < getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "solrconfig.xml"));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));- }- }-@Testpublic void testSingleFileOverwriteV1() throws Exception {testSingleFileOverwrite(false);@@ -1001,94 +796,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {}}- @Test- public void testSingleFileTrustedV1() throws Exception {- testSingleFileTrusted(false);- }-- @Test- public void testSingleFileTrustedV2() throws Exception {- testSingleFileTrusted(true);- }-- public void testSingleFileTrusted(boolean v2) throws Exception {- String configsetName = "regular";- String configsetSuffix = "testSinglePathTrusted-1-" + v2;- uploadConfigSetWithAssertions(configsetName, configsetSuffix, "solr");- try (SolrZkClient zkClient =- new SolrZkClient.Builder()- .withUrl(cluster.getZkServer().getZkAddress())- .withTimeout(AbstractZkTestCase.TIMEOUT, TimeUnit.MILLISECONDS)- .withConnTimeOut(45000, TimeUnit.MILLISECONDS)- .build()) {- assertEquals(- 0,- uploadSingleConfigSetFile(- configsetName,- configsetSuffix,- "solr",- "solr/configsets/upload/regular/solrconfig.xml",- "/test/upload/path/solrconfig.xml",- true,- false,- v2));- assertEquals(- "Expecting first version of new file",- 0,- getConfigZNodeVersion(- zkClient, configsetName, configsetSuffix, "test/upload/path/solrconfig.xml"));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));- assertConfigsetFiles(configsetName, configsetSuffix, zkClient);-- ignoreException("Trying to make an unstrusted ConfigSet update on a trusted configSet");- assertEquals(- "Can't upload a trusted configset with an untrusted request",- 400,- uploadSingleConfigSetFile(- configsetName,- configsetSuffix,- null,- "solr/configsets/upload/regular/solrconfig.xml",- "/test/different/path/solrconfig.xml",- true,- false,- v2));- assertFalse(- "New file should not exist, since the trust check did not succeed.",- zkClient.exists(- "/configs/" + configsetName + configsetSuffix + "/test/different/path/solrconfig.xml",- true));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));- assertConfigsetFiles(configsetName, configsetSuffix, zkClient);- unIgnoreException("Trying to make an unstrusted ConfigSet update on a trusted configSet");-- ignoreException("Trying to make an unstrusted ConfigSet update on a trusted configSet");- int extraFileZkVersion =- getConfigZNodeVersion(- zkClient, configsetName, configsetSuffix, "test/upload/path/solrconfig.xml");- assertEquals(- "Can't upload a trusted configset with an untrusted request",- 400,- uploadSingleConfigSetFile(- configsetName,- configsetSuffix,- null,- "solr/configsets/upload/regular/solrconfig.xml",- "/test/upload/path/solrconfig.xml",- true,- false,- v2));- assertEquals(- "Expecting version to remain equal",- extraFileZkVersion,- getConfigZNodeVersion(- zkClient, configsetName, configsetSuffix, "test/upload/path/solrconfig.xml"));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));- assertConfigsetFiles(configsetName, configsetSuffix, zkClient);- unIgnoreException("Trying to make an unstrusted ConfigSet update on a trusted configSet");- }- }-@Testpublic void testSingleFileForbiddenTypeV1() throws Exception {testSingleFileForbiddenType(false);@@ -1176,7 +883,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {0,getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "test/upload/path/solrconfig.xml"));- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix));assertConfigsetFiles(configsetName, configsetSuffix, zkClient);// New file with untrusted request@@ -1196,7 +902,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {0,getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "test/different/path/solrconfig.xml"));- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix));assertConfigsetFiles(configsetName, configsetSuffix, zkClient);// Overwrite with trusted request@@ -1219,7 +924,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {extraFileZkVersion< getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "test/different/path/solrconfig.xml"));- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix));assertConfigsetFiles(configsetName, configsetSuffix, zkClient);// Overwrite with untrusted request@@ -1242,7 +946,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {extraFileZkVersion< getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "test/upload/path/solrconfig.xml"));- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix));assertConfigsetFiles(configsetName, configsetSuffix, zkClient);// Make sure that cleanup flag does not result in configSet being trusted.@@ -1266,9 +969,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {extraFileZkVersion,getConfigZNodeVersion(zkClient, configsetName, configsetSuffix, "test/different/path/solrconfig.xml"));- assertFalse(- "The cleanup=true flag allowed for trust overwriting in a filePath upload.",- isTrusted(zkClient, configsetName, configsetSuffix));assertConfigsetFiles(configsetName, configsetSuffix, zkClient);unIgnoreException("ConfigSet uploads do not allow cleanup=true when filePath is used.");}@@ -1310,7 +1010,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {"Expecting first version of new file",0,getConfigZNodeVersion(zkClient, configsetName, configsetSuffixTrusted, "solrconfig.xml"));- assertTrue(isTrusted(zkClient, configsetName, configsetSuffixTrusted));List<String> children =zkClient.getChildren(String.format(Locale.ROOT, "/configs/%s%s", configsetName, configsetSuffixTrusted),@@ -1336,7 +1035,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {0,getConfigZNodeVersion(zkClient, configsetName, configsetSuffixUntrusted, "solrconfig.xml"));- assertFalse(isTrusted(zkClient, configsetName, configsetSuffixUntrusted));children =zkClient.getChildren(String.format(Locale.ROOT, "/configs/%s%s", configsetName, configsetSuffixUntrusted),@@ -1347,21 +1045,6 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {}}- private boolean isTrusted(SolrZkClient zkClient, String configsetName, String configsetSuffix)- throws KeeperException, InterruptedException {- String configSetZkPath =- String.format(Locale.ROOT, "/configs/%s%s", configsetName, configsetSuffix);- try {- byte[] configSetNodeContent = zkClient.getData(configSetZkPath, null, null, true);-- @SuppressWarnings("unchecked")- Map<Object, Object> contentMap = (Map<Object, Object>) Utils.fromJSON(configSetNodeContent);- return (boolean) contentMap.getOrDefault("trusted", true);- } catch (KeeperException.NoNodeException e) {- return true;- }- }-private int getConfigZNodeVersion(SolrZkClient zkClient, String configsetName, String configsetSuffix, String configFile)throws KeeperException, InterruptedException {@@ -1872,7 +1555,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {tmpConfigDir.resolve("configsetprops.json"),getConfigSetProps(Map.of("immutable", "true")),UTF_8);- getConfigSetService().uploadConfig("configSet", tmpConfigDir, false);+ getConfigSetService().uploadConfig("configSet", tmpConfigDir);// no ConfigSet nameDeleteNoErrorChecking delete = new DeleteNoErrorChecking();@@ -1900,7 +1583,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {final String baseUrl = cluster.getJettySolrRunners().get(0).getBaseUrl().toString();final SolrClient solrClient = getHttpSolrClient(baseUrl);final String configSet = "testDelete";- getConfigSetService().uploadConfig(configSet, configset("configset-2"), false);+ getConfigSetService().uploadConfig(configSet, configset("configset-2"));assertDelete(solrClient, configSet, true);assertDelete(solrClient, "configSetBogus", false);solrClient.close();@@ -1949,7 +1632,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {Set<String> configSets = new HashSet<String>();for (int i = 0; i < 5; ++i) {String configSet = "configSet" + i;- getConfigSetService().uploadConfig(configSet, configset("configset-2"), false);+ getConfigSetService().uploadConfig(configSet, configset("configset-2"));configSets.add(configSet);}response = list.process(solrClient);diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIExclusivity.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIExclusivity.javaindex 8ffa0292bee..6cc865c2fb9 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIExclusivity.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIExclusivity.java@@ -17,7 +17,6 @@package org.apache.solr.cloud;import java.lang.invoke.MethodHandles;-import java.nio.charset.StandardCharsets;import java.util.ArrayList;import java.util.Arrays;import java.util.List;@@ -93,12 +92,7 @@ public class TestConfigSetsAPIExclusivity extends SolrTestCaseJ4 {private void setupBaseConfigSet(String baseConfigSetName) throws Exception {solrCluster.uploadConfigSet(configset("configset-2"), baseConfigSetName);// Make configset untrusted- solrCluster- .getZkClient()- .setData(- "/configs/" + baseConfigSetName,- "{\"trusted\": false}".getBytes(StandardCharsets.UTF_8),- true);+ solrCluster.getZkClient();}private Exception getFirstExceptionOrNull(List<Exception> list) {diff --git a/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java b/solr/core/src/test/org/apache/solr/core/TestCodecSupport.javaindex 50987200800..849f6a997a7 100644--- a/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java+++ b/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java@@ -250,7 +250,7 @@ public class TestCodecSupport extends SolrTestCaseJ4 {new SolrCore(coreContainer,cd,- new ConfigSet("fakeConfigset", config, forceFetch -> schema, null, true));+ new ConfigSet("fakeConfigset", config, forceFetch -> schema, null));assertNull(coreContainer.registerCore(cd, c, false, false));h.coreName = newCoreName;assertEquals(diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigSetService.java b/solr/core/src/test/org/apache/solr/core/TestConfigSetService.javaindex 726ad98e8db..883567b6734 100644--- a/solr/core/src/test/org/apache/solr/core/TestConfigSetService.java+++ b/solr/core/src/test/org/apache/solr/core/TestConfigSetService.java@@ -26,7 +26,6 @@ import java.util.Arrays;import java.util.Collections;import java.util.HashMap;import java.util.List;-import java.util.Map;import java.util.function.Supplier;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.cloud.ZkConfigSetService;@@ -79,7 +78,7 @@ public class TestConfigSetService extends SolrTestCaseJ4 {Files.createDirectory(configDir.resolve("subdir"));Files.createFile(configDir.resolve("subdir").resolve("file3"));- configSetService.uploadConfig(configName, configDir, false);+ configSetService.uploadConfig(configName, configDir);assertTrue(configSetService.checkConfigExists(configName));assertFalse(configSetService.checkConfigExists("dummyConfig"));@@ -92,16 +91,8 @@ public class TestConfigSetService extends SolrTestCaseJ4 {configSetService.uploadFileToConfig(configName, "subdir/file4", data, true);assertArrayEquals(configSetService.downloadFileFromConfig(configName, "subdir/file4"), data);- Map<String, Object> metadata = configSetService.getConfigMetadata(configName);- assertFalse(metadata.isEmpty());- assertFalse(configSetService.isConfigSetTrusted(configName));-- configSetService.setConfigSetTrust(configName, true);- assertTrue(configSetService.isConfigSetTrusted(configName));-- configSetService.setConfigMetadataWithTrust(+ configSetService.setConfigMetadata(configName, new HashMap<>(Collections.singletonMap("foo", true)));- assertTrue(configSetService.isConfigSetTrusted(configName));assertTrue(configSetService.getConfigMetadata(configName).containsKey("foo"));List<String> configFiles = configSetService.getAllConfigFiles(configName);diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.javaindex 787bea658bc..2ef1cfc0188 100644--- a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java+++ b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java@@ -568,7 +568,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {public void copyConfig(String fromConfig, String toConfig) {}@Override- protected void uploadConfig(String configName, Path dir) {}+ public void uploadConfig(String configName, Path dir) {}@Overridepublic void uploadFileToConfig(diff --git a/solr/core/src/test/org/apache/solr/core/TestFileSystemConfigSetService.java b/solr/core/src/test/org/apache/solr/core/TestFileSystemConfigSetService.javaindex e4ceb1b831c..6e8b8fd3a41 100644--- a/solr/core/src/test/org/apache/solr/core/TestFileSystemConfigSetService.java+++ b/solr/core/src/test/org/apache/solr/core/TestFileSystemConfigSetService.java@@ -94,10 +94,9 @@ public class TestFileSystemConfigSetService extends SolrTestCaseJ4 {fileSystemConfigSetService.uploadFileToConfig(configName, "testfile", testdata, true);// metadata is stored in .metadata.json- fileSystemConfigSetService.setConfigMetadataWithTrust(- configName, new HashMap<>(Map.of("key1", "val1")));+ fileSystemConfigSetService.setConfigMetadata(configName, new HashMap<>(Map.of("key1", "val1")));Map<String, Object> metadata = fileSystemConfigSetService.getConfigMetadata(configName);- assertEquals("{key1=val1, trusted=true}", metadata.toString());+ assertEquals("{key1=val1}", metadata.toString());List<String> allConfigFiles = fileSystemConfigSetService.getAllConfigFiles(configName);assertEquals("[schema.xml, solrconfig.xml, testfile]", allConfigFiles.toString());diff --git a/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperReadAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperReadAPITest.javaindex 928109df2e0..41eddba832e 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperReadAPITest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperReadAPITest.java@@ -77,10 +77,10 @@ public class ZookeeperReadAPITest extends SolrCloudTestCase {final var configListRequest = new ZookeeperReadApi.ListNodes("/configs");final var configListResponse = configListRequest.process(client).getParsed();+assertEquals(- 16, configListResponse.unknownProperties().get("/configs").get("_default").dataLength);- assertEquals(- 16, configListResponse.unknownProperties().get("/configs").get("conf").dataLength);+ 6, configListResponse.unknownProperties().get("/configs").get("_default").children);+ assertEquals(2, configListResponse.unknownProperties().get("/configs").get("conf").children);assertEquals(0, configListResponse.stat.version);final var configDataRequest = new ZookeeperReadApi.ReadNode("/configs");diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/RestoreCollectionAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/RestoreCollectionAPITest.javaindex e4aab80a2df..63999f034db 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/api/RestoreCollectionAPITest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/RestoreCollectionAPITest.java@@ -30,7 +30,6 @@ import static org.apache.solr.common.params.CoreAdminParams.BACKUP_ID;import static org.apache.solr.common.params.CoreAdminParams.BACKUP_LOCATION;import static org.apache.solr.common.params.CoreAdminParams.BACKUP_REPOSITORY;import static org.apache.solr.common.params.CoreAdminParams.NAME;-import static org.apache.solr.common.params.CoreAdminParams.TRUSTED;import static org.hamcrest.Matchers.containsString;import java.util.List;@@ -133,7 +132,7 @@ public class RestoreCollectionAPITest extends SolrTestCaseJ4 {final var remoteMessage =restoreCollectionAPI.createRemoteMessage("someBackupName", requestBody).getProperties();- assertEquals(8, remoteMessage.size());+ assertEquals(7, remoteMessage.size());assertEquals("restore", remoteMessage.get(QUEUE_OPERATION));assertEquals("someCollectionName", remoteMessage.get(COLLECTION));assertEquals("/some/location/path", remoteMessage.get(BACKUP_LOCATION));@@ -141,7 +140,6 @@ public class RestoreCollectionAPITest extends SolrTestCaseJ4 {assertEquals("someRepositoryName", remoteMessage.get(BACKUP_REPOSITORY));assertEquals("someAsyncId", remoteMessage.get(ASYNC));assertEquals("someBackupName", remoteMessage.get(NAME));- assertFalse((Boolean) remoteMessage.get(TRUSTED));}@Test@@ -164,7 +162,7 @@ public class RestoreCollectionAPITest extends SolrTestCaseJ4 {final var remoteMessage =restoreCollectionAPI.createRemoteMessage("someBackupName", requestBody).getProperties();- assertEquals(15, remoteMessage.size());+ assertEquals(14, remoteMessage.size());assertEquals("restore", remoteMessage.get(QUEUE_OPERATION));assertEquals("someCollectionName", remoteMessage.get(COLLECTION));assertEquals("/some/location/path", remoteMessage.get(BACKUP_LOCATION));@@ -178,7 +176,6 @@ public class RestoreCollectionAPITest extends SolrTestCaseJ4 {assertEquals(Integer.valueOf(456), remoteMessage.get(TLOG_REPLICAS));assertEquals(Integer.valueOf(789), remoteMessage.get(PULL_REPLICAS));assertEquals("node1,node2", remoteMessage.get(CREATE_NODE_SET_PARAM));- assertFalse((Boolean) remoteMessage.get(TRUSTED));assertEquals("bar", remoteMessage.get("property.foo"));}diff --git a/solr/modules/scripting/src/java/org/apache/solr/scripting/update/ScriptUpdateProcessorFactory.java b/solr/modules/scripting/src/java/org/apache/solr/scripting/update/ScriptUpdateProcessorFactory.javaindex 3385532ba65..d1cf55a3385 100644--- a/solr/modules/scripting/src/java/org/apache/solr/scripting/update/ScriptUpdateProcessorFactory.java+++ b/solr/modules/scripting/src/java/org/apache/solr/scripting/update/ScriptUpdateProcessorFactory.java@@ -40,7 +40,6 @@ import javax.script.ScriptException;import org.apache.commons.io.FilenameUtils;import org.apache.lucene.util.IOUtils;import org.apache.solr.common.SolrException;-import org.apache.solr.common.SolrException.ErrorCode;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.solr.common.util.SuppressForbidden;@@ -216,13 +215,6 @@ public class ScriptUpdateProcessorFactory extends UpdateRequestProcessorFactory@Overridepublic void inform(SolrCore core) {- if (!core.getCoreDescriptor().isConfigSetTrusted()) {- throw new SolrException(- ErrorCode.UNAUTHORIZED,- "The configset for this collection was uploaded without any authentication in place,"- + " and this operation is not available for collections with untrusted configsets. To use this component, re-upload the configset"- + " after enabling authentication and authorization.");- }resourceLoader = core.getResourceLoader();// test that our engines & scripts are validdiff --git a/solr/modules/scripting/src/java/org/apache/solr/scripting/xslt/XSLTUpdateRequestHandler.java b/solr/modules/scripting/src/java/org/apache/solr/scripting/xslt/XSLTUpdateRequestHandler.javaindex f5530c769ff..54494c0bf29 100644--- a/solr/modules/scripting/src/java/org/apache/solr/scripting/xslt/XSLTUpdateRequestHandler.java+++ b/solr/modules/scripting/src/java/org/apache/solr/scripting/xslt/XSLTUpdateRequestHandler.java@@ -93,14 +93,6 @@ public class XSLTUpdateRequestHandler extends UpdateRequestHandler {return;}- if (req.getCore().getCoreDescriptor().isConfigSetTrusted() == false) {- throw new SolrException(- SolrException.ErrorCode.UNAUTHORIZED,- "The configset for this collection was uploaded without any authentication in place,"- + " and this operation is not available for collections with untrusted configsets. To use this feature, re-upload the configset"- + " after enabling authentication and authorization.");- }-final Transformer t = TransformerProvider.getTransformer(req, tr, xsltCacheLifetimeSeconds);final DOMResult result = new DOMResult();diff --git a/solr/solr-ref-guide/modules/deployment-guide/examples/ZkConfigFilesTest.java b/solr/solr-ref-guide/modules/deployment-guide/examples/ZkConfigFilesTest.javaindex f2fb303a7dd..f3d9c41fb1e 100644--- a/solr/solr-ref-guide/modules/deployment-guide/examples/ZkConfigFilesTest.java+++ b/solr/solr-ref-guide/modules/deployment-guide/examples/ZkConfigFilesTest.java@@ -70,8 +70,7 @@ public class ZkConfigFilesTest extends SolrCloudTestCase {assertConfigsContainOnly();// tag::zk-configset-upload[]- getConfigSetService()- .uploadConfig("nameForConfigset", Paths.get(localConfigSetDirectory), false);+ getConfigSetService().uploadConfig("nameForConfigset", Paths.get(localConfigSetDirectory));// end::zk-configset-upload[]assertConfigsContainOnly("nameForConfigset");diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adocindex 650b89b110c..444355bc2f4 100644--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc@@ -101,3 +101,7 @@ Users who that don't need to vary JAR access on a per-core basis have several op* Kerberos based authentication has been removed. This results in changes to SolrJ, the Solr Admin app, and the removal of the `hadoop-auth` module.* Storing indexes and snapshots in HDFS has been removed. This results in changes to solrconfig.xml and related configuration files and removal of the `hdfs` module.++=== Security++* There is no longer a distinction between trusted and untrusted configSets; all configSets are now considered trusted. To ensure security, Solr should be properly protected using authentication and authorization mechanisms, allowing only authorized users with administrative privileges to publish them.\ No newline at end of filediff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.java b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.javaindex 8dc77b154e2..9f726035691 100644--- a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.java+++ b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.java@@ -95,14 +95,13 @@ public class TestZkConfigSetService extends SolrTestCaseJ4 {Files.createDirectory(tempConfig.resolve(".ignoreddir"));Files.createFile(tempConfig.resolve(".ignoreddir").resolve("ignored"));- configSetService.uploadConfig("testconfig", tempConfig, true);+ configSetService.uploadConfig("testconfig", tempConfig);// uploading a directory creates a new configList<String> configs = configSetService.listConfigs();assertEquals(1, configs.size());assertEquals("testconfig", configs.get(0));assertTrue(configSetService.checkConfigExists("testconfig"));- assertTrue(configSetService.isConfigSetTrusted("testconfig"));// check downloadingPath downloadPath = createTempDir("download");@@ -120,17 +119,16 @@ public class TestZkConfigSetService extends SolrTestCaseJ4 {// uploading to the same config overwritesbyte[] overwritten = "new test data".getBytes(StandardCharsets.UTF_8);Files.write(tempConfig.resolve("file1"), overwritten);- configSetService.uploadConfig("testconfig", tempConfig, false);+ configSetService.uploadConfig("testconfig", tempConfig);assertEquals(1, configSetService.listConfigs().size());Path download2 = createTempDir("download2");configSetService.downloadConfig("testconfig", download2);byte[] checkdata2 = Files.readAllBytes(download2.resolve("file1"));assertArrayEquals(overwritten, checkdata2);- assertFalse(configSetService.isConfigSetTrusted("testconfig"));// uploading same files to a new name creates a new config- configSetService.uploadConfig("config2", tempConfig, true);+ configSetService.uploadConfig("config2", tempConfig);assertEquals(2, configSetService.listConfigs().size());// Test copying a config works in both flavors@@ -139,7 +137,6 @@ public class TestZkConfigSetService extends SolrTestCaseJ4 {configs = configSetService.listConfigs();assertTrue("config2copy should exist", configs.contains("config2copy"));assertTrue("config2copy2 should exist", configs.contains("config2copy2"));- assertTrue(configSetService.isConfigSetTrusted("config2"));}}@@ -191,7 +188,7 @@ public class TestZkConfigSetService extends SolrTestCaseJ4 {try (SolrZkClient client =buildZkClient(zkServer.getZkAddress("/acl"), aclProvider, writeable)) {ConfigSetService configSetService = new ZkConfigSetService(client);- configSetService.uploadConfig("acltest", configPath, false);+ configSetService.uploadConfig("acltest", configPath);assertEquals(1, configSetService.listConfigs().size());}@@ -202,8 +199,7 @@ public class TestZkConfigSetService extends SolrTestCaseJ4 {assertEquals(1, configSetService.listConfigs().size());IOException ioException =assertThrows(- IOException.class,- () -> configSetService.uploadConfig("acltest2", configPath, false));+ IOException.class, () -> configSetService.uploadConfig("acltest2", configPath));assertEquals(KeeperException.NoAuthException.class, ioException.getCause().getClass());}diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java b/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.javaindex 15d4397bd39..a85b3fe9ead 100644--- a/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java+++ b/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java@@ -159,9 +159,6 @@ public abstract class CoreAdminParams {*/public static final String REPLICA_TYPE = "replicaType";- /** Whether the request that generated the admin command is trusted */- public static final String TRUSTED = "trusted";-public enum CoreAdminAction {STATUS(true),UNLOAD,diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.javaindex fd61ae2c9c1..2cd9795b714 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java@@ -580,7 +580,7 @@ public class MiniSolrCloudCluster {.withTimeout(AbstractZkTestCase.TIMEOUT, TimeUnit.MILLISECONDS).withConnTimeOut(AbstractZkTestCase.TIMEOUT, TimeUnit.MILLISECONDS).build()) {- new ZkConfigSetService(zkClient).uploadConfig(configName, configDir, true);+ new ZkConfigSetService(zkClient).uploadConfig(configName, configDir);}}