2015-02-08 90 views
0

我需要通过我的安全来允许某个请求,但是我只想在它从某个位置到达我服务器上的特定位置时允许它。这是我当前的安全配置有关WebSecurity:Spring WebSecurity允​​许从url访问

@Override 
    public void configure(WebSecurity web) throws Exception 
    { 
     web 
     .ignoring() 
     .antMatchers("/authentication/login") 
     .antMatchers("https://stackoverflow.com/users/create") 
     .antMatchers("/services/**") 
     .antMatchers("/favicon.ico") 
     .antMatchers("/resources/**") 
     .antMatchers("/leagues/signupDetails/**"); 

     // allow from https://connect.stripe.com/ 
     // to 
     // "/stripeAccountConfirm" 
    } 

我敢肯定有办法做到这一点,但我是新来的整个配置的场景。提前致谢。

回答

1

你可以与Web安全表达式做到这一点:

... 
.antMatchers("/services/**").access("hasRole('admin') and hasIpAddress('192.168.10.0/32')") 
... 
相关问题