summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/libertacasa/pubsh/web
diff options
context:
space:
mode:
authorGeorg Pfuetzenreuter2022-05-06 21:56:06 +0200
committerGeorg Pfuetzenreuter2022-05-06 21:56:06 +0200
commitfc9f4b56b5f13bb8f5b7b22c5b96a6d6838439de (patch)
tree804eb28f02ad87838e617e9d35d1cc53bdffa02d /src/main/java/net/libertacasa/pubsh/web
parent20d049ea10c14eb335014b5c8d150f55bf437377 (diff)
downloadpubsh-web-fc9f4b56b5f13bb8f5b7b22c5b96a6d6838439de.tar.gz
pubsh-web-fc9f4b56b5f13bb8f5b7b22c5b96a6d6838439de.tar.bz2
pubsh-web-fc9f4b56b5f13bb8f5b7b22c5b96a6d6838439de.zip
Checkpoint
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
Diffstat (limited to 'src/main/java/net/libertacasa/pubsh/web')
-rw-r--r--src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java1
-rw-r--r--src/main/java/net/libertacasa/pubsh/web/WebApplication.java19
2 files changed, 12 insertions, 8 deletions
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<String, Object> customClaims = token.getOtherClaims();
username = String.valueOf(customClaims.get("username"));
-
- model.addAttribute("osChoice", osChoice);
-
+ //String osChoice = null;
+ //model.addAttribute("osChoice", osChoice);
+ //Map<String, Object> allAttributes = null;
+ //model.addAllAttributes(allAttributes);
+ //System.out.println(allAttributes);
System.out.printf("New container with OS %s requested by %s (%s)", osChoice, userid, username);