I have a webSecConfig class that extends WebSecurityConfigurerAdapter. I paste it's method where I tried to allow access with using .antMatchers. My folder structure: ... -resources --static (here I have images for the html/css) --templates ---login.html ---design.css I have tried adding a "public" folder based on some comments, but nothing seems to work so far. Can anyone help me with this please?
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.formLogin()
.loginPage("/login").permitAll()
.loginProcessingUrl("/login")
.defaultSuccessUrl("/messages", true)
.and()
.logout()
.logoutSuccessUrl("/login")
.logoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET"))
.and()
.authorizeRequests()
.antMatchers("/login", "resources/**").permitAll()
.anyRequest().authenticated();
}
I managed to solve it! I put my css's in a css folder inside resources/static. And I used "/css/**" in the antMatchers section. Also href to the css should be: href="/css/design.css", my IDE has refactored it as href="../static/css/design.css" wich is WRONG, so look out for this! I hope it will help someone!