summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java1
-rw-r--r--src/main/java/net/libertacasa/pubsh/web/WebApplication.java19
-rw-r--r--src/main/resources/templates/portal.html8
3 files changed, 17 insertions, 11 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);
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 @@
</table>
<h2>Generate new throw-away shell:</h2>
- <select th:field="*{availableOs}" class="form-control" id="osChoice" name="osChoice">
+ <select th:field="*{availableOs}" class="form-control" th:id="osChoice" th:name="osChoice">
<option value="">Select operating system ...</option>
<option
th:each="osoption : ${availableOs}"
th:value="${osoption}"
th:text="${osoption}"></option>
</select>
- <form th:object="${osChoice}" id="request_pseudoform" action="#" th:action="@{'/frontend/container/add}" th:method="post" th:os="${osChoice}" th:onsubmit="return confirm('You are about to generate a shell with the OS ' + this.getAttribute('os') + ' - please be patient after you confirm, as the generation may take a short while.');">
- <button class="btn btn-primary" id="request_submission" type="submit">Generate</button>
+
+ <form th:object="${osChoice}" th:id="request_pseudoform" action="#" th:action="@{'/frontend/container/add'}" th:method="post" th:os="${osChoice}" th:onsubmit="return confirm('You are about to generate a shell with the OS ' + this.getAttribute('os') + ' - please be patient after you confirm, as the generation may take a short while.');">
+ <input th:type="hidden" th:method="post" th:name="osChoice" th:value="osChoice" th:attr="value = ${osChoice}" />
+ <button class="btn btn-primary" th:id="request_submission" th:type="submit">Generate</button>
</form>