У меня есть базовое приложение SpringBoot 2.1.5.RELEASE.Использование Spring Initializer, JPA, встроенного Tomcat, механизма шаблонов Thymeleaf и пакета в качестве исполняемого файла JAR.
У меня был этот шаблон Thymeleaf, который работает нормально с именем входа
<form id="loginForm" th:action="@{/login}" method="post">
<div class="input_label"><i class="fa fa-user"></i><input type="text" id="usernameId" name="username" th:attr="placeholder=#{login.user.placeholder}" /></div>
<div class="input_label"><i class="fa fa-key"></i><input type="text" name="password" placeholder="Password" /></div>
<input type="submit" value="LOGIN" />
</form>
, которое я заменяюдля другого:
<form id="loginForm" th:action="@{/login}" method="post">
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend"><i class="icon s7-user"></i></div>
<input class="form-control" id="username" name="username" type="text" th:attr="placeholder=#{login.user.placeholder}" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend"><i class="icon s7-lock"></i></div>
<input class="form-control" id="password" name="password" type="password" placeholder="Password">
</div>
</div>
<div class="form-group login-submit">
<a class="btn btn-lg btn-primary btn-block" th:href="@{/login}" data-dismiss="modal">Login</a>
</div>
<div class="form-group row login-tools">
<div class="col-sm-6 login-remember">
<label class="custom-control custom-checkbox mt-2">
<input class="custom-control-input" type="checkbox"><span class="custom-control-label">Remember me</span>
</label>
</div>
<div class="col-sm-6 pt-2 text-sm-right login-forgot-password"><a href="pages-forgot-password.html">Forgot Password?</a></div>
</div>
</form>
Но даже если кажется, что аутентификация в порядке, вот консоль:
2019-05-22 15:09 [http-nio-2233-exec-8] DEBUG o.s.s.w.a.i.FilterSecurityInterceptor.authenticateIfRequired(348) - Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@afd2c118: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@ffff4c9c: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: DD587EDE4D70B2AC1D1609FD3553FB31; Granted Authorities: ROLE_ANONYMOUS
2019-05-22 15:09 [http-nio-2233-exec-8] DEBUG o.s.s.access.vote.AffirmativeBased.decide(66) - Voter: org.springframework.security.web.access.expression.WebExpressionVoter@976c509, returned: 1
2019-05-22 15:09 [http-nio-2233-exec-8] DEBUG o.s.s.w.a.i.FilterSecurityInterceptor.beforeInvocation(243) - Authorization successful
2019-05-22 15:09 [http-nio-2233-exec-8] DEBUG o.s.s.w.a.i.FilterSecurityInterceptor.beforeInvocation(256) - RunAsManager did not change Authentication object
Приложение не перенаправляет на страницу, которую я настроил вфайл конфигурации
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers(publicMatchers()).permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").defaultSuccessUrl("/bonanza/all")
.failureUrl("/login?error").permitAll()
.and()
.logout().permitAll();
}