diff options
author | Georg Pfuetzenreuter | 2022-05-07 14:12:55 +0200 |
---|---|---|
committer | Georg Pfuetzenreuter | 2022-05-07 14:12:55 +0200 |
commit | e37ec4083a8fff705185956bb8fa3b29f3c05ff8 (patch) | |
tree | 701c484bf7983b8819fac4b7f29d8d26cbdc6471 /src/main/java | |
parent | fc9f4b56b5f13bb8f5b7b22c5b96a6d6838439de (diff) | |
download | pubsh-web-e37ec4083a8fff705185956bb8fa3b29f3c05ff8.tar.gz pubsh-web-e37ec4083a8fff705185956bb8fa3b29f3c05ff8.tar.bz2 pubsh-web-e37ec4083a8fff705185956bb8fa3b29f3c05ff8.zip |
Checkpoint: Working OS-picker
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/WebApplication.java | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java index 9d64592..e7b3cd2 100644 --- a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java +++ b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java @@ -16,9 +16,11 @@ import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken; import org.keycloak.representations.IDToken; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.http.MediaType; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.DeleteMapping; //import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -118,20 +120,15 @@ public class WebApplication { return("redirect:/portal"); } - @PostMapping("/frontend/container/add") - //public static String addContainer(@PathVariable HttpServletRequest request, Model model) { - public static String addContainer(@RequestBody String osChoice, Model model,HttpServletRequest request) { + @PostMapping(path="/frontend/container/add",consumes=MediaType.APPLICATION_FORM_URLENCODED_VALUE) + public static String addContainer(@RequestBody MultiValueMap<String, String> body, HttpServletRequest request) { 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")); - //String osChoice = null; - //model.addAttribute("osChoice", osChoice); - //Map<String, Object> allAttributes = null; - //model.addAllAttributes(allAttributes); - //System.out.println(allAttributes); + String osChoice = (String) body.getFirst("osChoice"); System.out.printf("New container with OS %s requested by %s (%s)", osChoice, userid, username); @@ -141,7 +138,6 @@ public class WebApplication { //Docker.buildImage(username, osChoice, count); - return("redirect:/portal"); } |