На странице аутентификации не работают css-стили (Spring Boot + Thymeleaf)
Столкнулся с такой проблемой: не работают css-стили на странице аутентификации. На всех остальных страницах проблем нет. Проект на Spring Boot + Thymeleaf. Я добавил исключения в SecurityConfig, но они почему-то не срабатывают. Пробовал так же без configure(WebSecurity web), результат тот же.
login.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" >
<title>ESNP страница авторизации</title>
<link rel="stylesheet" th:href="@{/styles/css/login.css}" type="text/css"/>
</head>
<body>
<div>
<form name="f" method="POST" action="/process_login">
<label for="username">Введите имя пользователя</label>
<input type="text" name="username" id="username"/>
<br>
<label for="password">Введите пароль</label>
<input type="password" name="password" id="password"/>
<input type="submit" value="Login">
<div th:if="${param.error}" style="color: red">
Неправильное имя или пароль
</div>
</form>
</div>
</body>
</html>
SecurityConfig
package net.myt.esnp.config;
import net.myt.esnp.services.PersonDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private final PersonDetailsService personDetailsService;
@Autowired
public SecurityConfig(PersonDetailsService personDetailsService) {
this.personDetailsService = personDetailsService;
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(personDetailsService);
}
@Bean
public PasswordEncoder getPasswordEncoder() {
return new BCryptPasswordEncoder();
}
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/**")
.antMatchers("/auth/login", "/register", "/api/public/**")
.antMatchers("/css/**", "/fonts/**", "/images/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/css/style.css","/js/bootstrap.js","/css/style.scss").permitAll()
.antMatchers("/people/registration", "/auth/login", "/error").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/auth/login")
.loginProcessingUrl("/process_login")
.defaultSuccessUrl("/auth/hello", true)
.failureUrl("/auth/login?error")
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/auth/login");
}
}