mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-346 Session expire time config parameter
This commit is contained in:
@@ -82,6 +82,7 @@ type ServerConfig {
|
||||
supportsCustomConnections: Boolean
|
||||
supportsConnectionBrowser: Boolean
|
||||
supportsWorkspaces: Boolean
|
||||
sessionExpireTime: Int
|
||||
|
||||
configurationMode: Boolean
|
||||
developmentMode: Boolean
|
||||
|
||||
@@ -87,6 +87,11 @@ public class WebServerConfig {
|
||||
return application.isDevelMode();
|
||||
}
|
||||
|
||||
@Property
|
||||
public long getSessionExpireTime() {
|
||||
return application.getMaxSessionIdleTime();
|
||||
}
|
||||
|
||||
@Property
|
||||
public WebServerLanguage[] getSupportedLanguages() {
|
||||
List<PlatformLanguageDescriptor> langs = PlatformLanguageRegistry.getInstance().getLanguages();
|
||||
|
||||
@@ -407,6 +407,7 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
String newServerName,
|
||||
String adminName,
|
||||
String adminPassword,
|
||||
long sessionExpireTime,
|
||||
CBAppConfig appConfig) throws DBException
|
||||
{
|
||||
if (!RECONFIGURATION_ALLOWED && !isConfigurationMode()) {
|
||||
@@ -417,7 +418,7 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
|
||||
// Save runtime configuration
|
||||
log.debug("Saving runtime configuration");
|
||||
saveRuntimeConfig(newServerName, appConfig);
|
||||
saveRuntimeConfig(newServerName, sessionExpireTime, appConfig);
|
||||
|
||||
// Grant permissions to predefined connections
|
||||
if (appConfig.isAnonymousAccessEnabled()) {
|
||||
@@ -457,7 +458,7 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveRuntimeConfig(String newServerName, CBAppConfig appConfig) throws DBException {
|
||||
private void saveRuntimeConfig(String newServerName, long sessionExpireTime, CBAppConfig appConfig) throws DBException {
|
||||
|
||||
File runtimeConfigFile = getRuntimeConfigFile();
|
||||
try (Writer out = new OutputStreamWriter(new FileOutputStream(runtimeConfigFile), StandardCharsets.UTF_8)) {
|
||||
@@ -471,7 +472,10 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
json.name("server");
|
||||
json.beginObject();
|
||||
if (!CommonUtils.isEmpty(newServerName)) {
|
||||
JSONUtils.field(json, "serverName", newServerName);
|
||||
JSONUtils.field(json, CBConstants.PARAM_SERVER_NAME, newServerName);
|
||||
}
|
||||
if (sessionExpireTime > 0) {
|
||||
JSONUtils.field(json, CBConstants.PARAM_SESSION_EXPIRE_PERIOD, sessionExpireTime);
|
||||
}
|
||||
json.endObject();
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ input ServerConfigInput {
|
||||
anonymousAccessEnabled: Boolean
|
||||
authenticationEnabled: Boolean
|
||||
customConnectionsEnabled: Boolean
|
||||
|
||||
sessionExpireTime: Int
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
|
||||
+12
@@ -34,6 +34,8 @@ public class AdminServerConfig {
|
||||
private boolean authenticationEnabled;
|
||||
private boolean customConnectionsEnabled;
|
||||
|
||||
private long sessionExpireTime;
|
||||
|
||||
public AdminServerConfig(Map<String, Object> params) {
|
||||
this.serverName = JSONUtils.getString(params, "serverName");
|
||||
this.adminName = JSONUtils.getString(params, "adminName");
|
||||
@@ -42,6 +44,8 @@ public class AdminServerConfig {
|
||||
this.anonymousAccessEnabled = JSONUtils.getBoolean(params, "anonymousAccessEnabled");
|
||||
this.authenticationEnabled = JSONUtils.getBoolean(params, "authenticationEnabled");
|
||||
this.customConnectionsEnabled = JSONUtils.getBoolean(params, "customConnectionsEnabled");
|
||||
|
||||
this.sessionExpireTime = JSONUtils.getLong(params, "sessionExpireTime", -1);
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
@@ -91,4 +95,12 @@ public class AdminServerConfig {
|
||||
public void setCustomConnectionsEnabled(boolean customConnectionsEnabled) {
|
||||
this.customConnectionsEnabled = customConnectionsEnabled;
|
||||
}
|
||||
|
||||
public long getSessionExpireTime() {
|
||||
return sessionExpireTime;
|
||||
}
|
||||
|
||||
public void setSessionExpireTime(long sessionExpireTime) {
|
||||
this.sessionExpireTime = sessionExpireTime;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -307,6 +307,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
config.getServerName(),
|
||||
config.getAdminName(),
|
||||
config.getAdminPassword(),
|
||||
config.getSessionExpireTime(),
|
||||
appConfig);
|
||||
// Refresh active session
|
||||
webSession.forceUserRefresh(null);
|
||||
|
||||
Reference in New Issue
Block a user