Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring安全性允许一个url_Spring_Spring Security - Fatal编程技术网

Spring安全性允许一个url

Spring安全性允许一个url,spring,spring-security,Spring,Spring Security,我已经使用spring实现了一个Rest api,并使用spring安全性保护该api,我的安全配置代码是: http .authorizeRequests() .anyRequest().authenticated() .and() .requestCache() .requestCache(new NullRequestCache()) .and() .httpBasic(); 此代码将验证所有url,但我希望允许匿名用

我已经使用spring实现了一个Rest api,并使用spring安全性保护该api,我的安全配置代码是:

http
     .authorizeRequests()
     .anyRequest().authenticated()
     .and()
     .requestCache()
     .requestCache(new NullRequestCache())
     .and()
     .httpBasic();
此代码将验证所有url,但我希望允许匿名用户在我的应用程序中注册特定url,因此我将安全配置更改为以下代码:

http
     .authorizeRequests()
     .antMatchers("/signup").permitAll()
     .antMatchers("/**").authenticated()
     .and()
     .requestCache()
     .requestCache(new NullRequestCache())
     .and()
     .httpBasic();
但是我仍然需要通过身份验证才能访问/signup请求调用。
如何在api中只允许一些请求调用?

我应该使用WebSecurity参数覆盖configure方法,并使用以下代码忽略/signup请求

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

我应该用WebSecurity参数覆盖configure方法,并使用以下代码忽略/signup请求

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

下面这个链接应该解决你的问题:谢谢这个解决我的问题下面这个链接应该解决你的问题:谢谢这个解决我的问题