From fc9f4b56b5f13bb8f5b7b22c5b96a6d6838439de Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Fri, 6 May 2022 21:56:06 +0200 Subject: Checkpoint Signed-off-by: Georg Pfuetzenreuter --- .../net/libertacasa/pubsh/web/SecurityConfig.java | 1 + .../net/libertacasa/pubsh/web/WebApplication.java | 19 +++++++++++-------- src/main/resources/templates/portal.html | 8 +++++--- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src/main') diff --git a/src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java b/src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java index 53f83ab..630acf4 100644 --- a/src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java +++ b/src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java @@ -32,6 +32,7 @@ public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable(); super.configure(http); //.anonymous().disable() http .authorizeRequests() diff --git a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java index ca6ea7e..9d64592 100644 --- a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java +++ b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java @@ -26,13 +26,15 @@ import org.springframework.web.bind.annotation.ModelAttribute; //import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.github.dockerjava.api.model.Container; import com.github.dockerjava.api.model.Image; import java.util.Random; - +//@SessionAttributes("osChoice") @SpringBootApplication @Controller public class WebApplication { @@ -93,9 +95,7 @@ public class WebApplication { availableOs.add("opensuse-tumbleweed"); availableOs.add("ubuntu"); model.addAttribute("availableOs", availableOs); - model.addAttribute("osChoice", new String()); - - + //model.addAttribute("osChoice", new String()); return("portal"); } @@ -119,16 +119,19 @@ public class WebApplication { } @PostMapping("/frontend/container/add") - public static String addContainer(@PathVariable String osChoice, HttpServletRequest request, Model model) { + //public static String addContainer(@PathVariable HttpServletRequest request, Model model) { + public static String addContainer(@RequestBody String osChoice, Model model,HttpServletRequest request) { KeycloakAuthenticationToken principal = (KeycloakAuthenticationToken) request.getUserPrincipal(); String username= null; String userid = principal.getName(); IDToken token = principal.getAccount().getKeycloakSecurityContext().getIdToken(); Map customClaims = token.getOtherClaims(); username = String.valueOf(customClaims.get("username")); - - model.addAttribute("osChoice", osChoice); - + //String osChoice = null; + //model.addAttribute("osChoice", osChoice); + //Map allAttributes = null; + //model.addAllAttributes(allAttributes); + //System.out.println(allAttributes); System.out.printf("New container with OS %s requested by %s (%s)", osChoice, userid, username); diff --git a/src/main/resources/templates/portal.html b/src/main/resources/templates/portal.html index eb3c765..66c5ad1 100644 --- a/src/main/resources/templates/portal.html +++ b/src/main/resources/templates/portal.html @@ -17,15 +17,17 @@

Generate new throw-away shell:

- -
- + + + +
-- cgit v1.2.3