improvements, additional security dialect

This commit is contained in:
kwandzel 2018-02-17 16:59:50 +01:00
parent 6642fc53a4
commit 77735a57fd
4 changed files with 11 additions and 9 deletions

View File

@ -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");
}
}

View File

@ -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";

View File

@ -8,5 +8,8 @@
<p>Spring Security Thymeleaf tutorial</p>
<div sec:authorize="hasRole('USER')">Text visible to user.</div>
<div sec:authorize="hasRole('ADMIN')">Text visible to admin.</div>
<div sec:authorize="isAuthenticated()">Text visible only to authenticated users.</div>
Authenticated username: <div sec:authentication="name"></div>
Authenticated user roles: <div sec:authentication="principal.authorities"></div>
</body>
</html>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Insert title here</title>
<title>Custom Login Page</title>
</head>
<body>
<h2>Custom Login Page</h2>