Spring Security exclude url patterns in security annotation configurartion

后端 未结 4 1852
迷失自我
迷失自我 2020-11-29 01:23

I have spring web application with Spring security configured using java config approach. I want to exclude some URL patterns from authentication(eg: static resources etc..)

4条回答
  •  臣服心动
    2020-11-29 02:08

    Found the solution in Spring security examples posted in Github.

    WebSecurityConfigurerAdapter has a overloaded configure message that takes WebSecurity as argument which accepts ant matchers on requests to be ignored.

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/authFailure");
    }
    

    See Spring Security Samples for more details

提交回复
热议问题