Я не знаю, как сделать что-то с весенней безопасностью, и я надеюсь, что вы, ребята, поможете мне.
У меня есть два контроллера: один для страницы входа и один для домашней страницы
@RestController
@RequestMapping("/rest/hello")
public class LoginController {
@GetMapping(value="/login")
public String getLoginPage(Model model){
return "login";
}
}
и
@RestController
@RequestMapping("/rest/hello")
public class HomeController {
@GetMapping("/home")
public String getHomePage() {
return "homePage";
}
}
Для этого контроллера у меня есть html-страницы,
login.html
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<div class="login100-form-title" style="background-image: url(images/bg-01.png);">
</div>
<form class="login100-form validate-form">
<div class="wrap-input100 validate-input m-b-26" data-validate="Username is required">
<span class="label-input100">Username</span>
<input class="input100" type="text" name="username" placeholder="Enter username">
<span class="focus-input100"></span>
</div>
<div class="wrap-input100 validate-input m-b-18" data-validate = "Password is required">
<span class="label-input100">Password</span>
<input class="input100" type="password" name="pass" placeholder="Enter password">
<span class="focus-input100"></span>
</div>
<div class="flex-sb-m w-full p-b-30">
<div class="contact100-form-checkbox">
<input class="input-checkbox100" id="ckb1" type="checkbox" name="remember-me">
<label class="label-checkbox100" for="ckb1">
Remember me
</label>
</div>
<div>
</div>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn">
Login
</button>
</div>
</form>
</div>
</div>
</div>
Файл ldif и конфигурация, которая выглядит так:
@EnableGlobalMethodSecurity
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.formLogin();
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource(contextSource())
.passwordCompare()
.passwordEncoder(new LdapShaPasswordEncoder())
.passwordAttribute("userPassword");
}
@Bean
public DefaultSpringSecurityContextSource contextSource() {
return new DefaultSpringSecurityContextSource(Arrays.asList("ldap://localhost:8389/"),
"dc=springframework,dc=org");
}
}
Прежде всего, я хочу использовать форму входа в систему, а не форму по умолчанию. Если я попытаюсь сделать это в моей конфигурации
.formLogin().loginPage("/login");
Я получаю эту ошибку: эта страница не работает
localhost перенаправил вас слишком много раз.
Попробуйте очистить куки
И моя вторая проблема в том, что после аутентификации я хочу перенаправить меня на домашнюю страницу, но вместо этого я получаю сообщение с именем html-файла: "homePage"