From 77735a57fd196e683dfb49c0c8deedab652d2bcf Mon Sep 17 00:00:00 2001 From: kwandzel Date: Sat, 17 Feb 2018 16:59:50 +0100 Subject: [PATCH] improvements, additional security dialect --- .../springsecuritythymeleaf/SecurityConfiguration.java | 7 +++---- .../baeldung/springsecuritythymeleaf/ViewController.java | 8 ++++---- .../src/main/resources/templates/index.html | 3 +++ .../src/main/resources/templates/login.html | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/spring-security-thymeleaf/src/main/java/com/baeldung/springsecuritythymeleaf/SecurityConfiguration.java b/spring-security-thymeleaf/src/main/java/com/baeldung/springsecuritythymeleaf/SecurityConfiguration.java index 185093adfa..9c734a6b2d 100644 --- a/spring-security-thymeleaf/src/main/java/com/baeldung/springsecuritythymeleaf/SecurityConfiguration.java +++ b/spring-security-thymeleaf/src/main/java/com/baeldung/springsecuritythymeleaf/SecurityConfiguration.java @@ -30,9 +30,8 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - auth - .inMemoryAuthentication() - .withUser("user").password("password").roles("USER").and() - .withUser("admin").password("admin").roles("ADMIN"); + auth.inMemoryAuthentication() + .withUser("user").password("password").roles("USER").and() + .withUser("admin").password("admin").roles("ADMIN"); } } diff --git a/spring-security-thymeleaf/src/main/java/com/baeldung/springsecuritythymeleaf/ViewController.java b/spring-security-thymeleaf/src/main/java/com/baeldung/springsecuritythymeleaf/ViewController.java index 2f2fa69608..81b891dad8 100644 --- a/spring-security-thymeleaf/src/main/java/com/baeldung/springsecuritythymeleaf/ViewController.java +++ b/spring-security-thymeleaf/src/main/java/com/baeldung/springsecuritythymeleaf/ViewController.java @@ -5,17 +5,17 @@ import org.springframework.web.bind.annotation.RequestMapping; @Controller public class ViewController { - + @RequestMapping("/login") public String login() { return "login"; } - - @RequestMapping({"/index", "/"}) + + @RequestMapping({ "/index", "/" }) public String index() { return "index"; } - + @RequestMapping("/loginError") public String loginError() { return "loginError"; diff --git a/spring-security-thymeleaf/src/main/resources/templates/index.html b/spring-security-thymeleaf/src/main/resources/templates/index.html index 6cbc8f867e..c127f7c663 100644 --- a/spring-security-thymeleaf/src/main/resources/templates/index.html +++ b/spring-security-thymeleaf/src/main/resources/templates/index.html @@ -8,5 +8,8 @@

Spring Security Thymeleaf tutorial

Text visible to user.
Text visible to admin.
+
Text visible only to authenticated users.
+ Authenticated username:
+ Authenticated user roles:
\ No newline at end of file diff --git a/spring-security-thymeleaf/src/main/resources/templates/login.html b/spring-security-thymeleaf/src/main/resources/templates/login.html index 49cbedabf2..92cade03ec 100644 --- a/spring-security-thymeleaf/src/main/resources/templates/login.html +++ b/spring-security-thymeleaf/src/main/resources/templates/login.html @@ -1,7 +1,7 @@ -Insert title here +Custom Login Page

Custom Login Page