mirror of https://github.com/apache/cloudstack.git
Hide CloudStack version from XML response when unauthenticated (#10575)
This commit is contained in:
parent
54b44cc316
commit
6059724189
|
|
@ -20,6 +20,7 @@ import com.cloud.api.ApiDBUtils;
|
|||
import com.cloud.api.ApiResponseGsonHelper;
|
||||
import com.cloud.api.ApiServer;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.server.ManagementServerImpl;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.HttpUtils;
|
||||
import com.cloud.utils.encoding.URLEncoder;
|
||||
|
|
@ -171,9 +172,18 @@ public class ApiResponseSerializer {
|
|||
if (result != null && log != null) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
sb.append("<").append(result.getResponseName()).append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\">");
|
||||
log.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
log.append("<").append(result.getResponseName()).append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\">");
|
||||
|
||||
sb.append("<").append(result.getResponseName());
|
||||
log.append("<").append(result.getResponseName());
|
||||
|
||||
boolean authenticated = CallContext.current().getCallingAccount().getId() != Account.ACCOUNT_ID_SYSTEM;
|
||||
if (ManagementServerImpl.exposeCloudStackVersionInApiXmlResponse.value() && authenticated) {
|
||||
sb.append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\"");
|
||||
log.append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\"");
|
||||
}
|
||||
sb.append(">");
|
||||
log.append(">");
|
||||
|
||||
if (result instanceof ListResponse) {
|
||||
Integer count = ((ListResponse)result).getCount();
|
||||
|
|
|
|||
|
|
@ -870,6 +870,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
static final ConfigKey<Integer> sshKeyLength = new ConfigKey<>("Advanced", Integer.class, "ssh.key.length", "2048", "Specifies custom SSH key length (bit)", true, ConfigKey.Scope.Global);
|
||||
static final ConfigKey<Boolean> humanReadableSizes = new ConfigKey<>("Advanced", Boolean.class, "display.human.readable.sizes", "true", "Enables outputting human readable byte sizes to logs and usage records.", false, ConfigKey.Scope.Global);
|
||||
public static final ConfigKey<String> customCsIdentifier = new ConfigKey<>("Advanced", String.class, "custom.cs.identifier", UUID.randomUUID().toString().split("-")[0].substring(4), "Custom identifier for the cloudstack installation", true, ConfigKey.Scope.Global);
|
||||
public static final ConfigKey<Boolean> exposeCloudStackVersionInApiXmlResponse = new ConfigKey<Boolean>("Advanced", Boolean.class, "expose.cloudstack.version.api.xml.response", "true", "Indicates whether ACS version should appear in the root element of an API XML response.", true, ConfigKey.Scope.Global);
|
||||
public static final ConfigKey<Boolean> exposeCloudStackVersionInApiListCapabilities = new ConfigKey<Boolean>("Advanced", Boolean.class, "expose.cloudstack.version.api.list.capabilities", "true", "Indicates whether ACS version should show in the listCapabilities API.", true, ConfigKey.Scope.Global);
|
||||
|
||||
private static final VirtualMachine.Type []systemVmTypes = { VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.ConsoleProxy};
|
||||
private static final List<HypervisorType> LIVE_MIGRATION_SUPPORTING_HYPERVISORS = List.of(HypervisorType.Hyperv, HypervisorType.KVM,
|
||||
HypervisorType.LXC, HypervisorType.Ovm, HypervisorType.Ovm3, HypervisorType.Simulator, HypervisorType.VMware, HypervisorType.XenServer);
|
||||
|
|
@ -4227,7 +4230,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {vmPasswordLength, sshKeyLength, humanReadableSizes, customCsIdentifier};
|
||||
return new ConfigKey<?>[] {exposeCloudStackVersionInApiXmlResponse, exposeCloudStackVersionInApiListCapabilities, vmPasswordLength, sshKeyLength, humanReadableSizes, customCsIdentifier};
|
||||
}
|
||||
|
||||
protected class EventPurgeTask extends ManagedContextRunnable {
|
||||
|
|
@ -4665,10 +4668,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
|
||||
final Integer fsVmMinCpu = Integer.parseInt(_configDao.getValue("sharedfsvm.min.cpu.count"));
|
||||
final Integer fsVmMinRam = Integer.parseInt(_configDao.getValue("sharedfsvm.min.ram.size"));
|
||||
if (exposeCloudStackVersionInApiListCapabilities.value()) {
|
||||
capabilities.put("cloudStackVersion", getVersion());
|
||||
}
|
||||
|
||||
capabilities.put("securityGroupsEnabled", securityGroupsEnabled);
|
||||
capabilities.put("userPublicTemplateEnabled", userPublicTemplateEnabled);
|
||||
capabilities.put("cloudStackVersion", getVersion());
|
||||
capabilities.put("supportELB", supportELB);
|
||||
capabilities.put("projectInviteRequired", _projectMgr.projectInviteRequired());
|
||||
capabilities.put("allowusercreateprojects", _projectMgr.allowUserToCreateProject());
|
||||
|
|
|
|||
Loading…
Reference in New Issue