Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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/1/cassandra/3.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
Java 使用Spring安全性授权POST端点_Java_Spring_Spring Mvc_Spring Boot_Spring Security - Fatal编程技术网

Java 使用Spring安全性授权POST端点

Java 使用Spring安全性授权POST端点,java,spring,spring-mvc,spring-boot,spring-security,Java,Spring,Spring Mvc,Spring Boot,Spring Security,我的Spring项目中有一个REST端点/public/signUser;我想在没有凭据的情况下授权此终结点,以便允许创建用户。但是,如果我尝试对signUser端点执行POST请求,我会收到未经授权的错误。我想为此端点禁用身份验证 @配置 @启用Web安全性 @EnableGlobalMethodSecurity(Prespenabled=true) 公共类SecurityConfig扩展了WebSecurity配置适配器{ @注入 私有用户详细信息服务用户详细信息服务; @凌驾 受保护的无效

我的Spring项目中有一个REST端点
/public/signUser
;我想在没有凭据的情况下授权此终结点,以便允许创建用户。但是,如果我尝试对
signUser
端点执行
POST
请求,我会收到未经授权的错误。我想为此端点禁用身份验证

@配置
@启用Web安全性
@EnableGlobalMethodSecurity(Prespenabled=true)
公共类SecurityConfig扩展了WebSecurity配置适配器{
@注入
私有用户详细信息服务用户详细信息服务;
@凌驾
受保护的无效配置(AuthenticationManagerBuilder auth)引发异常{
auth.userDetailsService(userDetailsService)
.passwordEncoder(新的BCryptPasswordEncoder());
}
@凌驾
受保护的无效配置(HttpSecurity http)引发异常{
http.httpBasic()和()
.会议管理()
.sessionCreationPolicy(sessionCreationPolicy.STATELESS)
.及()
.授权请求()
.antMatchers(HttpMethod.POST,“/public/signUser”).permitAll()
.antMatchers(“/public/hello”、“/swagger ui/**”、“/api docs/**”).permitAll()
.antMatchers(“/protected/**”).authenticated()
.及()
.httpBasic()
.realmName(“PlcManager”)
.及()
.csrf()
.disable();
}
}

我尝试过.antMatchers(HttpMethod.POST,“/public/signUser”).permitAll()和.antMatchers(“/public/hello”、“/swagger ui/**”、“/api docs/**”).permitAll()但不起作用。你能暂时删除HttpMethod.POST并进行测试吗?我尝试过.antMatchers(HttpMethod.POST,“/public/signUser”).permitAll()和.antMatchers(“/public/hello”、“/swagger ui/**”、“/api docs/**”)。permitAll()但不是works您可以删除HttpMethod.POST进行while和test吗?