diff options
author | Georg Pfuetzenreuter | 2022-05-08 15:07:14 +0200 |
---|---|---|
committer | Georg Pfuetzenreuter | 2022-05-08 15:07:14 +0200 |
commit | b48fe2fd1086892b439454ad3843705baf34b58b (patch) | |
tree | 5cb18f652c7ad89c282b0299234873321702ad2b /src/main/java | |
parent | a014a0126fa72c9b1630c718d05f1652dfc13fb8 (diff) | |
download | pubsh-web-b48fe2fd1086892b439454ad3843705baf34b58b.tar.gz pubsh-web-b48fe2fd1086892b439454ad3843705baf34b58b.tar.bz2 pubsh-web-b48fe2fd1086892b439454ad3843705baf34b58b.zip |
Move shell deletion to separate mapping
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/libertacasa/pubsh/web/Docker.java | 1 | ||||
-rw-r--r-- | src/main/java/net/libertacasa/pubsh/web/WebApplication.java | 21 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/main/java/net/libertacasa/pubsh/web/Docker.java b/src/main/java/net/libertacasa/pubsh/web/Docker.java index a889703..ff81be3 100644 --- a/src/main/java/net/libertacasa/pubsh/web/Docker.java +++ b/src/main/java/net/libertacasa/pubsh/web/Docker.java @@ -15,7 +15,6 @@ import com.github.dockerjava.api.command.ListContainersCmd; import com.github.dockerjava.api.command.ListImagesCmd; import com.github.dockerjava.api.command.WaitContainerResultCallback; import com.github.dockerjava.api.model.Image; -import com.github.dockerjava.api.model.SearchItem; import com.github.dockerjava.core.DefaultDockerClientConfig; import com.github.dockerjava.core.DockerClientConfig; import com.github.dockerjava.core.DockerClientImpl; diff --git a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java index 4c06c29..c9cbe07 100644 --- a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java +++ b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java @@ -157,8 +157,7 @@ public class WebApplication { System.out.printf("Deletion triggered for ID %s by %s (%s)\n", id, userid, username); - //Docker.deleteContainer(id); - Docker.deleteShell(username, id); //to-do: move to separate mapping + Docker.deleteContainer(id); return("redirect:/portal"); } @@ -248,6 +247,24 @@ public class WebApplication { } return("redirect:/portal"); + } + + @DeleteMapping("/frontend/shell/delete/{id}") + public static String deleteShell(@PathVariable String id, HttpServletRequest request, RedirectAttributes redirectAttributes) { + // [Start] This block should move to a logging method. It's only job is to print user details to the console. + KeycloakAuthenticationToken principal = (KeycloakAuthenticationToken) request.getUserPrincipal(); + String username= null; + String userid = principal.getName(); + IDToken token = principal.getAccount().getKeycloakSecurityContext().getIdToken(); + Map<String, Object> customClaims = token.getOtherClaims(); + username = String.valueOf(customClaims.get("username")); + // [End] + + System.out.printf("Deletion triggered for ID %s by %s (%s)\n", id, userid, username); + + Docker.deleteShell(username, id); + + return("redirect:/portal"); } @GetMapping(path = "/logout") |