Hi Here is My Security Config File and i'm using Spring Boot 2.0.6.RELEASE and my static content files are in static folder only static->css, js, images, fonts
i have tried all the other posts solution but none of them worked for me and still static contents are secured styles are not getting applied etc. thanks in advance
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private final String[] PUBLIC_MATCHER = {"/css/**","/js/**","/fonts/**","/images/**", "/"};
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers(PUBLIC_MATCHER)
.permitAll().anyRequest().authenticated()
.and()
.csrf().disable().cors().disable()
.formLogin().failureUrl("/login?error").defaultSuccessUrl("/dashboard")
.loginPage("/login").permitAll()
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/?logout").deleteCookies("remember-me").permitAll()
.and()
.rememberMe();
}
}
}
Add this method in your security Config file,hope it will work
//this method allows static resources to be neglected by spring security
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/**", "/static/**","/css/**","/js/**","/fonts/**","/images/**");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.