[BAEL-1556]:fixes according to a review
This commit is contained in:
parent
b021e6b01a
commit
94421b7d38
@ -14,13 +14,14 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.authorizeRequests()
|
||||
.anyRequest().authenticated()
|
||||
http.authorizeRequests()
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.and()
|
||||
.formLogin()
|
||||
.loginPage("/login")
|
||||
.permitAll().failureUrl("/loginError").successForwardUrl("/index")
|
||||
.permitAll()
|
||||
.successForwardUrl("/index")
|
||||
.and()
|
||||
.logout()
|
||||
.permitAll()
|
||||
@ -31,7 +32,12 @@ 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");
|
||||
.withUser("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.and()
|
||||
.withUser("admin")
|
||||
.password("admin")
|
||||
.roles("ADMIN");
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,4 @@ public class ViewController {
|
||||
public String index() {
|
||||
return "index";
|
||||
}
|
||||
|
||||
@RequestMapping("/loginError")
|
||||
public String loginError() {
|
||||
return "loginError";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,8 +8,11 @@
|
||||
<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>
|
||||
<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>
|
@ -7,9 +7,9 @@
|
||||
<h2>Custom Login Page</h2>
|
||||
<form th:action="@{/login}" method="post">
|
||||
<label for="username">Username</label>: <input type="text"
|
||||
id="username" name="username" autofocus="autofocus" /> <br /> <label
|
||||
id="username" name="username" autofocus="autofocus" /> <label
|
||||
for="password">Password</label>: <input type="password" id="password"
|
||||
name="password" /> <br /> <input type="submit" value="Log in" />
|
||||
name="password" /><input type="submit" value="Log in" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Login error page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Login Error Page</h2>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user