z
Size: a a a
z
z
z
z
AE
AE
АО
IV
IV
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/**","/static/**");
}
protected void configure (AuthenticationManagerBuilder builder) throws Exception {
builder.inMemoryAuthentication().withUser("user").password("12345").roles("user");
}
protected void configure (HttpSecurity http) throws Exception {
http.authorizeRequests().
anyRequest().authenticated().
and().formLogin().loginPage("/login")
.loginProcessingUrl("authenticateMe").permitAll();
IV
<body>
<form method="post" th:action="@{/authenticateMe}" class="login">
<p>
<label th:for="Username">Username: </label>
<input type="text" th:name="username" id="username"/>
</p>
<p>
<label th:for="Password">Password: </label>
<input type="password" th:name="password" id="password"/>
</p>
<p class="login-submit">
<button type="submit" class="login-button">Login</button>
</p>
</form>
IV
@org.springframework.stereotype.Controller
public class Controller {
@GetMapping("/login")
public String showLogin () {
return "index";
}
S
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/**","/static/**");
}
protected void configure (AuthenticationManagerBuilder builder) throws Exception {
builder.inMemoryAuthentication().withUser("user").password("12345").roles("user");
}
protected void configure (HttpSecurity http) throws Exception {
http.authorizeRequests().
anyRequest().authenticated().
and().formLogin().loginPage("/login")
.loginProcessingUrl("authenticateMe").permitAll();
IV
IV
protected void configure (HttpSecurity http) throws Exception {
http.authorizeRequests().
anyRequest().authenticated().
and().formLogin().loginPage("/login")
.loginProcessingUrl("authenticateMe").permitAll().defaultSuccessUrl("/start", true);
IV
@GetMapping("/start")
public String login () {
return "login-page";
}
IV
IV
VS
РН