Reputation: 222
Unfortunately, I stucked. Situation: My app run good, but when I fitted it with Spring-Boot-Security, the all css, js, img folder become unaccessible....
I tried to adopt the MVCConfig properties in my application.properties file, but it didn't work. :( (spring.mvc.static-path-pattern=/resources/**)
Upvotes: 0
Views: 52
Reputation: 4310
You have to create a WebSecurityConfigurerAdapter
class to set security settings. Note that you need to specify unprotected urls as follows.
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/assets/**", "/favicon.ico").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
}
}
Upvotes: 2