Java 未经授权的用户访问某些url
我使用Oauth并希望创建用户,但有错误Java 未经授权的用户访问某些url,java,spring-boot,spring-security,Java,Spring Boot,Spring Security,我使用Oauth并希望创建用户,但有错误 POST http://localhost:4200/proxy/user/createUser 401 (Unauthorized) 在春天,我有一些配置 @Configuration @EnableWebSecurity public class WebSecurity extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSec
POST http://localhost:4200/proxy/user/createUser 401 (Unauthorized)
在春天,我有一些配置
@Configuration
@EnableWebSecurity
public class WebSecurity extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/createUser", "/user/**", "/user/createUser", "proxy/user/createUser").permitAll();
http.csrf().disable();
http.formLogin().disable();
http.authorizeRequests().anyRequest().authenticated();
}
}
及
启用对
。/createUser
的访问需要哪些配置更改?看起来像http.authorizeRequests().anyRequest().authorized()
,这在代码中造成了问题。只需将WebSecurity
更改为
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests().antMatchers("/createUser", "/user/**", "/user/createUser", "proxy/user/createUser")
.permitAll()
.formLogin().disable();
}}`
及
ResourceServerConfig
as中的更改
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests().antMatchers("/createUser", "/user/**", "/user/createUser", "proxy/user/createUser")
.permitAll()
.formLogin().disable();
}}`
http.authorizeRequests()
.antMatchers(“/createUser”、“/register”、“/token”、“/token/createUser”,
“代理/用户/创建用户”)
.permitAll()代码>
有关签出的详细信息。仍然未经授权您是否在ResourceServerConfig
中进行了更改?是的,但我必须在Websecurity http.formLogin().disable()中进行更改因为我有错误无法解决方法我也有AuthorizationServerConfig可能这个类会产生冲突您可以只尝试一次您正在尝试的端点,即在antMatchers中仅使用“proxy/user/createUser”
?这样我们至少可以知道这个终点发生了什么。谢谢