Vojtech Szocs has uploaded a new change for review. Change subject: webadmin: Adapt UI plugin infra REST session timeout ......................................................................
webadmin: Adapt UI plugin infra REST session timeout Engine session expiration happens through periodic job (SessionDataContainer#cleanExpiredUsersSessions) whose periodicity is the same as Engine session timeout value (UserSessionTimeOutInterval). Because of that, Engine sessions can stay active up to 2 * UserSessionTimeOutInterval. Refer to Einav's comment at http://gerrit.ovirt.org/#/c/36622/ for details. In this patch, we adapt REST session timeout to be 2 * UserSessionTimeOutInterval. Change-Id: Ifa95dba9b1f9647369bd817995c1cbd86f1e528f Bug-Url: https://bugzilla.redhat.com/1172726 Bug-Url: https://bugzilla.redhat.com/1168842 Signed-off-by: Vojtech Szocs <vsz...@redhat.com> --- M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java 1 file changed, 18 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/36737/1 diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java index 29a06cf..90a859d 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java @@ -75,7 +75,7 @@ private static final String ENGINE_AUTH_TOKEN_HEADER = "OVIRT-INTERNAL-ENGINE-AUTH-TOKEN"; //$NON-NLS-1$ private static final String SESSION_ID_KEY = "RestApiSessionId"; //$NON-NLS-1$ - private static final String DEFAULT_SESSION_TIMEOUT = "30"; //$NON-NLS-1$ + private static final int DEFAULT_ENGINE_SESSION_TIMEOUT = 30; //$NON-NLS-1$ // Heartbeat (delay) between REST API keep-alive requests private static final int SESSION_HEARTBEAT_MS = 1000 * 60; // 1 minute @@ -83,7 +83,7 @@ private final EventBus eventBus; private final String restApiBaseUrl; - private String restApiSessionTimeout = DEFAULT_SESSION_TIMEOUT; + private int restApiSessionTimeout; private String restApiSessionId; private boolean refreshRestApiSession = false; @@ -97,6 +97,7 @@ // this causes problems in other applications, for example in the reports application. this.restApiBaseUrl = BaseContextPathData.getInstance().getPath() + "api/"; //$NON-NLS-1$ + setSessionTimeout(DEFAULT_ENGINE_SESSION_TIMEOUT); eventBus.addHandler(EngineSessionRefreshedEvent.getType(), this); } @@ -107,8 +108,20 @@ } } - public void setSessionTimeout(String sessionTimeout) { - this.restApiSessionTimeout = sessionTimeout; + public void setSessionTimeout(String engineSessionTimeout) { + try { + setSessionTimeout(Integer.valueOf(engineSessionTimeout)); + } catch (NumberFormatException ex) { + setSessionTimeout(DEFAULT_ENGINE_SESSION_TIMEOUT); + } + } + + public void setSessionTimeout(int engineSessionTimeout) { + // Engine session expiration happens through periodic "cleanExpiredUsersSessions" job + // whose periodicity is same as Engine session timeout (UserSessionTimeOutInterval). + // Because of that, Engine sessions can stay active up to 2 * UserSessionTimeOutInterval + // so we adapt REST API session timeout accordingly. + restApiSessionTimeout = 2 * engineSessionTimeout; } /** @@ -118,7 +131,7 @@ RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, restApiBaseUrl); // Control REST API session timeout - builder.setHeader("Session-TTL", restApiSessionTimeout); //$NON-NLS-1$ + builder.setHeader("Session-TTL", String.valueOf(restApiSessionTimeout)); //$NON-NLS-1$ // Express additional preferences for serving this request builder.setHeader(PREFER_HEADER, "persistent-auth, csrf-protection"); //$NON-NLS-1$ -- To view, visit http://gerrit.ovirt.org/36737 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa95dba9b1f9647369bd817995c1cbd86f1e528f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Vojtech Szocs <vsz...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches