diff options
author | Georg Pfuetzenreuter | 2022-05-08 05:06:04 +0200 |
---|---|---|
committer | Georg Pfuetzenreuter | 2022-05-08 05:06:04 +0200 |
commit | 8b218230027fd5a8c7ed92fdc7d501fd94302149 (patch) | |
tree | 2d606c6e066552d7a906253957f7971d4d5c0201 /src/main/java/net/libertacasa | |
parent | cbec25cd6b5fe37f3010ab163b1bca61a743c457 (diff) | |
download | pubsh-web-8b218230027fd5a8c7ed92fdc7d501fd94302149.tar.gz pubsh-web-8b218230027fd5a8c7ed92fdc7d501fd94302149.tar.bz2 pubsh-web-8b218230027fd5a8c7ed92fdc7d501fd94302149.zip |
Cleanups, fix admin role
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
Diffstat (limited to 'src/main/java/net/libertacasa')
-rw-r--r-- | src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java | 2 | ||||
-rw-r--r-- | src/main/java/net/libertacasa/pubsh/web/WebApplication.java | 24 |
2 files changed, 12 insertions, 14 deletions
diff --git a/src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java b/src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java index 14b6dcb..d10efc5 100644 --- a/src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java +++ b/src/main/java/net/libertacasa/pubsh/web/SecurityConfig.java @@ -36,7 +36,7 @@ public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter { http .authorizeRequests() .antMatchers("/portal").hasAuthority("devel-user") - .antMatchers("/admin").hasAuthority("devel-admins") + .antMatchers("/admin").hasAuthority("devel-admin") .anyRequest().permitAll(); } } diff --git a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java index ad9ed9b..ed517e4 100644 --- a/src/main/java/net/libertacasa/pubsh/web/WebApplication.java +++ b/src/main/java/net/libertacasa/pubsh/web/WebApplication.java @@ -34,6 +34,13 @@ import com.github.dockerjava.api.model.Image; public class WebApplication { static ArrayList<String> availableOs = new ArrayList<String>(); + + private void genOsList() { + availableOs.add("archlinux"); + availableOs.add("opensuse-leap"); + availableOs.add("opensuse-tumbleweed"); + availableOs.add("ubuntu"); + } public static void main(String[] args) { SpringApplication.run(WebApplication.class, args); @@ -49,7 +56,6 @@ public class WebApplication { public String portal(Model model) throws pubshError { KeycloakAuthenticationToken authentication = (KeycloakAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); - Principal principal = (Principal) authentication.getPrincipal(); String username=""; String email=""; @@ -62,8 +68,6 @@ public class WebApplication { if (principal instanceof KeycloakPrincipal) { KeycloakPrincipal<?> kPrincipal = (KeycloakPrincipal<?>) principal; IDToken token = kPrincipal.getKeycloakSecurityContext().getIdToken(); - //System.out.println("Token: " + token); - Map<String, Object> customClaims = token.getOtherClaims(); if (! customClaims.containsKey("username")) { System.out.println("Fatal: received logon without username."); @@ -85,21 +89,13 @@ public class WebApplication { } List<Image> images = Docker.getImages(null); - - //System.out.println(images); List<Container> containers = Docker.getContainers(null); - //System.out.println(containers); model.addAttribute("docker_images", images); model.addAttribute("docker_containers", containers); - ArrayList<String> availableOs = new ArrayList<String>(); - availableOs.add("archlinux"); - availableOs.add("opensuse-leap"); - availableOs.add("opensuse-tumbleweed"); - availableOs.add("ubuntu"); + genOsList(); model.addAttribute("availableOs", availableOs); - //model.addAttribute("osChoice", new String()); return("admin"); } @@ -139,11 +135,13 @@ public class WebApplication { model.addAttribute("attribute01", attribute01); } - List<Image> images = Docker.getImages(username); + List<Image> images = Docker.getImages(username); List<Container> containers = Docker.getContainers(username); model.addAttribute("docker_images", images); model.addAttribute("docker_containers", containers); + + genOsList(); model.addAttribute("availableOs", availableOs); return("portal"); |