mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Merge pull request #673 from dbeaver/feature/CB-1669
CB-1669 api for driver exclusion
This commit is contained in:
@@ -142,6 +142,7 @@ type ServerConfig {
|
||||
productConfiguration: Object!
|
||||
productInfo: ProductInfo!
|
||||
defaultNavigatorSettings: NavigatorSettings!
|
||||
disabledDrivers: [ID!]!
|
||||
}
|
||||
|
||||
type SessionInfo {
|
||||
@@ -189,6 +190,7 @@ type DriverInfo {
|
||||
driverInfoURL: String
|
||||
driverPropertiesURL: String
|
||||
embedded: Boolean
|
||||
enabled: Boolean!
|
||||
|
||||
# this fields must be removed and be replaced by DriverAuthModel
|
||||
allowsEmptyPassword: Boolean @deprecated
|
||||
|
||||
+5
@@ -19,6 +19,7 @@ package io.cloudbeaver.model;
|
||||
import io.cloudbeaver.DBWebException;
|
||||
import io.cloudbeaver.WebServiceUtils;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.server.ConfigurationUtils;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.model.DBConstants;
|
||||
import org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor;
|
||||
@@ -233,4 +234,8 @@ public class WebDatabaseDriverConfig {
|
||||
.toArray(WebPropertyInfo[]::new);
|
||||
}
|
||||
|
||||
@Property
|
||||
public boolean isEnabled() {
|
||||
return ConfigurationUtils.isDriverEnabled(driver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,4 +189,9 @@ public class WebServerConfig {
|
||||
return new WebProductInfo();
|
||||
}
|
||||
|
||||
@Property
|
||||
public String[] getDisabledDrivers() {
|
||||
return application.getAppConfiguration().getDisabledDrivers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -166,6 +166,10 @@ public class CBAppConfig {
|
||||
return disabledDrivers;
|
||||
}
|
||||
|
||||
public void setDisabledDrivers(String[] disabledDrivers) {
|
||||
this.disabledDrivers = disabledDrivers;
|
||||
}
|
||||
|
||||
public boolean isFeatureEnabled(String id) {
|
||||
return ArrayUtils.contains(getEnabledFeatures(), id);
|
||||
}
|
||||
|
||||
@@ -801,6 +801,9 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
if (appConfig.getEnabledDrivers() != null) {
|
||||
JSONUtils.serializeStringList(json, "enabledDrivers", Arrays.asList(appConfig.getEnabledDrivers()), true);
|
||||
}
|
||||
if (appConfig.getDisabledDrivers() != null) {
|
||||
JSONUtils.serializeStringList(json, "disabledDrivers", Arrays.asList(appConfig.getDisabledDrivers()), true);
|
||||
}
|
||||
|
||||
if (!CommonUtils.isEmpty(appConfig.getPlugins())) {
|
||||
JSONUtils.serializeProperties(json, "plugins", appConfig.getPlugins());
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package io.cloudbeaver.server;
|
||||
|
||||
import io.cloudbeaver.model.session.WebSessionManager;
|
||||
import io.cloudbeaver.registry.WebDriverRegistry;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.jkiss.code.NotNull;
|
||||
@@ -302,9 +301,6 @@ public class CBPlatform extends BasePlatformImpl {
|
||||
|
||||
for (DBPDataSourceProviderDescriptor dspd : DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders()) {
|
||||
for (DBPDriver driver : dspd.getEnabledDrivers()) {
|
||||
if (!WebDriverRegistry.getInstance().isDriverEnabled(driver)) {
|
||||
continue;
|
||||
}
|
||||
List<? extends DBPDriverLibrary> libraries = driver.getDriverLibraries();
|
||||
{
|
||||
boolean hasAllFiles = true;
|
||||
|
||||
+6
-4
@@ -85,14 +85,16 @@ public class ConfigurationUtils {
|
||||
|
||||
public static boolean isDriverEnabled(@NotNull DBPDriver driver) {
|
||||
var driverId = driver.getFullId();
|
||||
|
||||
String[] disabledDrivers = CBApplication.getInstance().getAppConfiguration().getDisabledDrivers();
|
||||
if (ArrayUtils.contains(disabledDrivers, driverId)) {
|
||||
return false;
|
||||
}
|
||||
String[] enabledDrivers = CBApplication.getInstance().getAppConfiguration().getEnabledDrivers();
|
||||
if (enabledDrivers.length > 0 && !ArrayUtils.contains(enabledDrivers, driverId)) {
|
||||
return false;
|
||||
}
|
||||
String[] disabledDrivers = CBApplication.getInstance().getAppConfiguration().getDisabledDrivers();
|
||||
if (disabledDrivers.length > 0 && ArrayUtils.contains(disabledDrivers, driverId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ input ServerConfigInput {
|
||||
|
||||
enabledFeatures: [ID!]
|
||||
enabledAuthProviders: [ID!]
|
||||
enabledDrivers: [ID!]
|
||||
disabledDrivers: [ID!]
|
||||
|
||||
sessionExpireTime: Int
|
||||
}
|
||||
|
||||
+11
@@ -42,6 +42,7 @@ public class AdminServerConfig {
|
||||
private final List<String> enabledFeatures;
|
||||
private final List<String> enabledAuthProviders;
|
||||
private final String[] enabledDrivers;
|
||||
private final String[] disabledDrivers;
|
||||
|
||||
private long sessionExpireTime;
|
||||
|
||||
@@ -76,6 +77,12 @@ public class AdminServerConfig {
|
||||
} else {
|
||||
this.enabledDrivers = appConfig.getEnabledDrivers();
|
||||
}
|
||||
|
||||
if (params.containsKey("disabledDrivers")) {
|
||||
this.disabledDrivers = JSONUtils.getStringList(params, "disabledDrivers").toArray(new String[0]);
|
||||
} else {
|
||||
this.disabledDrivers = appConfig.getDisabledDrivers();
|
||||
}
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
@@ -145,4 +152,8 @@ public class AdminServerConfig {
|
||||
public String[] getEnabledDrivers() {
|
||||
return enabledDrivers;
|
||||
}
|
||||
|
||||
public String[] getDisabledDrivers() {
|
||||
return disabledDrivers;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -474,6 +474,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
appConfig.setAdminCredentialsSaveEnabled(config.isAdminCredentialsSaveEnabled());
|
||||
appConfig.setEnabledFeatures(config.getEnabledFeatures().toArray(new String[0]));
|
||||
appConfig.setEnabledDrivers(config.getEnabledDrivers());
|
||||
appConfig.setDisabledDrivers(config.getDisabledDrivers());
|
||||
|
||||
if (CommonUtils.isEmpty(config.getEnabledAuthProviders())) {
|
||||
// All of them
|
||||
|
||||
Reference in New Issue
Block a user