Skip to content

Commit ecb40a3

Browse files
committed
Stop apps on http session destroy
1 parent 05fe6e7 commit ecb40a3

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/service/ProxyService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public Command stopProxy(Authentication user, Proxy proxy, boolean ignoreAccessC
301301
throw new AccessDeniedException(String.format("Cannot stop proxy %s: access denied", proxy.getId()));
302302
}
303303

304-
if (user != null) {
304+
if (user != null && !ignoreAccessControl) {
305305
log.info(proxy, "Proxy being stopped by user " + UserService.getUserId(user));
306306
}
307307

@@ -341,7 +341,7 @@ public Command pauseProxy(Authentication user, Proxy proxy, boolean ignoreAccess
341341
throw new IllegalArgumentException("Trying to pause a proxy when the backend does not support pausing apps");
342342
}
343343

344-
if (user != null) {
344+
if (user != null && !ignoreAccessControl) {
345345
log.info(proxy, "Proxy being paused by user " + UserService.getUserId(user));
346346
}
347347

src/main/java/eu/openanalytics/containerproxy/service/UserService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public void onHttpSessionDestroyedEvent(HttpSessionDestroyedEvent event) {
221221
if (securityContext == null) return;
222222

223223
String userId = getUserId(securityContext.getAuthentication());
224+
if (logoutStrategy != null) logoutStrategy.onLogout(userId);
224225

225226
log.info(String.format("User logged out [user: %s]", userId));
226227
applicationEventPublisher.publishEvent(new UserLogoutEvent(
@@ -230,6 +231,8 @@ public void onHttpSessionDestroyedEvent(HttpSessionDestroyedEvent event) {
230231
));
231232
} else if (authBackend.getName().equals("none")) {
232233
String userId = Sha256.hash(event.getSession().getId());
234+
if (logoutStrategy != null) logoutStrategy.onLogout(userId);
235+
233236
log.info(String.format("Anonymous user logged out [user: %s]", userId));
234237
applicationEventPublisher.publishEvent(new UserLogoutEvent(
235238
this,

0 commit comments

Comments
 (0)