Move shell deletion to separate mapping
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
a014a0126f
commit
b48fe2fd10
@ -15,7 +15,6 @@ import com.github.dockerjava.api.command.ListContainersCmd;
|
|||||||
import com.github.dockerjava.api.command.ListImagesCmd;
|
import com.github.dockerjava.api.command.ListImagesCmd;
|
||||||
import com.github.dockerjava.api.command.WaitContainerResultCallback;
|
import com.github.dockerjava.api.command.WaitContainerResultCallback;
|
||||||
import com.github.dockerjava.api.model.Image;
|
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.DefaultDockerClientConfig;
|
||||||
import com.github.dockerjava.core.DockerClientConfig;
|
import com.github.dockerjava.core.DockerClientConfig;
|
||||||
import com.github.dockerjava.core.DockerClientImpl;
|
import com.github.dockerjava.core.DockerClientImpl;
|
||||||
|
@ -157,8 +157,7 @@ public class WebApplication {
|
|||||||
|
|
||||||
System.out.printf("Deletion triggered for ID %s by %s (%s)\n", id, userid, username);
|
System.out.printf("Deletion triggered for ID %s by %s (%s)\n", id, userid, username);
|
||||||
|
|
||||||
//Docker.deleteContainer(id);
|
Docker.deleteContainer(id);
|
||||||
Docker.deleteShell(username, id); //to-do: move to separate mapping
|
|
||||||
|
|
||||||
return("redirect:/portal");
|
return("redirect:/portal");
|
||||||
}
|
}
|
||||||
@ -250,6 +249,24 @@ public class WebApplication {
|
|||||||
return("redirect:/portal");
|
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")
|
@GetMapping(path = "/logout")
|
||||||
public String logout(HttpServletRequest request) throws ServletException {
|
public String logout(HttpServletRequest request) throws ServletException {
|
||||||
request.logout();
|
request.logout();
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
<td th:text="${container.id}" />
|
<td th:text="${container.id}" />
|
||||||
<td th:text="${container.status}" />
|
<td th:text="${container.status}" />
|
||||||
<td>
|
<td>
|
||||||
<form id="deletion_pseudoform" action="#" th:action="@{'/frontend/container/delete/{id}'(id=${container.id})}" th:method="delete" th:containerid="${container.id}" th:containerShaSum="${container.imageId}" th:onsubmit="return confirm('Do you really want to delete the container with ID ' + this.getAttribute('containerid') + ' which is attached to the image with checksum ' + this.getAttribute('containerShaSum') + ' ?');">
|
<form id="deletion_pseudoform" action="#" th:action="@{'/frontend/shell/delete/{id}'(id=${container.id})}" th:method="delete" th:containerid="${container.id}" th:containerShaSum="${container.imageId}" th:onsubmit="return confirm('Do you really want to delete the container with ID ' + this.getAttribute('containerid') + ' which is attached to the image with checksum ' + this.getAttribute('containerShaSum') + ' ?');">
|
||||||
<button class="btn btn-danger" id="deletion_submission" type="submit">Delete</button>
|
<button class="btn btn-danger" id="deletion_submission" type="submit">Delete</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user