Java 在spring引导运行中禁用特定uri上的curl身份验证
我正在尝试禁用应用程序中特定uri的身份验证,运行以下curl命令:Java 在spring引导运行中禁用特定uri上的curl身份验证,java,authentication,curl,spring-boot,Java,Authentication,Curl,Spring Boot,我正在尝试禁用应用程序中特定uri的身份验证,运行以下curl命令: curl --header "content-type: application/soap+xml" -d @src/test/resources/xml-file https://localhost:5434/ws --insecure 目前,它仅适用于: curl -u *****:***** --header "content-type: application/soap+xml" -d @src/test/reso
curl --header "content-type: application/soap+xml" -d @src/test/resources/xml-file https://localhost:5434/ws --insecure
目前,它仅适用于:
curl -u *****:***** --header "content-type: application/soap+xml" -d @src/test/resources/xml-fike https://localhost:5434/ws --insecure
以下是我更新的confifure方法:
@Override
public void configure(HttpSecurity http) throws Exception{
http.anonymous()
.and()
.antMatcher("/ws");
http.authorizeRequests()
.antMatchers("/rest").access("hasRole('USER', 'ADMIN')")
.anyRequest()
.authenticated();
System.out.println("applying anomyous to ws, and auth for rest");
}
这个解决方案基于到目前为止我在堆栈上找到的类似帖子,尽管当我运行所需的curl命令时,我没有得到任何输出。我仍然需要对我的“/rest”uri进行身份验证。用户凭据按以下方式初始化:
@Configuration
public class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
// overides deafult password, here you can add additional users
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("*******").password("*****").roles("USER")
.and()
.withUser("*******").password("******").roles("USER", "ADMIN");
System.out.println("global configurer finished");
}
}
我看过的一些帖子:
我用更新了configure方法,但仍然没有得到所需的输出
public void configure(HttpSecurity http) throws Exception{
http.
.antMatchers("/ws")
.permitAll()
.anonymous();
}
所以我尝试添加这个方法,但它需要额外的方法。但我不知道要补充什么
permitAll
仍然需要身份验证,由于您尚未启用匿名身份验证,因此您需要始终进行身份验证。我已将其更改为匿名,但仍然无效。您没有更改任何内容。您只添加了anonymous
并删除了permitAll
。您需要保留该选项。我用permitAll更新了我的配置方法,但我无法使该方法正常工作permitAll
仍然需要身份验证,并且由于您尚未启用匿名身份验证,结果是您需要始终进行身份验证。我已将其更改为匿名,但仍然无效您没有更改任何内容。您只添加了anonymous
并删除了permitAll
。你需要保留它。我用permitAll更新了配置方法,但无法使该方法正常工作