[SOLVED] Spring Security allow webjars through

So if you implemented Spring Security in your project, you might have problems with webjars not being allowed through. You need to set this configuration in your WebSecurityConfiguration:

 
[code language=”java”]
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/webjars/**").permitAll();
http.authorizeRequests().anyRequest().authenticated();
http.formLogin()
.loginPage("/login")
.failureUrl("/login?error")
.usernameParameter("email")
.permitAll()
.and()
.logout()
.logoutUrl("/logout")
.deleteCookies("remember-me")
.logoutSuccessUrl("/")
.permitAll()
.and()
.rememberMe();
}
[/code]
 

Leave a Reply

Your email address will not be published. Required fields are marked *