CB-346 Session expire time config parameter

This commit is contained in:
serge-rider
2020-10-10 18:01:20 +03:00
parent e69622a4b0
commit 89bd30b603
6 changed files with 28 additions and 3 deletions
@@ -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 {
@@ -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;
}
}
@@ -307,6 +307,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
config.getServerName(),
config.getAdminName(),
config.getAdminPassword(),
config.getSessionExpireTime(),
appConfig);
// Refresh active session
webSession.forceUserRefresh(null);