Home > AI > Backend > SpringBoot > spring-boot-starter-security >

WebSecurity

It is higher priority than HTTPSecurity. Usually it exposes static resources

For example, exposing css, js, images, and other resources

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {


    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                    .antMatchers("/good","/good-second").permitAll()
                    .anyRequest().authenticated()

    }






    @Override
    public void configure(WebSecurity web) throws Exception {
        web
                .ignoring()
                .antMatchers("/resources/**",
                        "/static/**",
                        "/css/**",
                        "/js/**",
                        "/images/**");
    }




}

Leave a Reply