Java Spring[Cloud]Oauth2排除微服务上的url
首先为我的英语道歉 我正在尝试使用微服务架构开发应用程序 当我有端点like/restaurant时,我有restaurant模块,我希望该端点对所有人公开 雅马哈酒店(餐厅) 我尝试在方法之前编写@PreAuthorize(“permitAll”)和@PreAuthorize(“permitAll()”)。 我在资源服务器上也尝试了:Java Spring[Cloud]Oauth2排除微服务上的url,java,spring-boot,microservices,Java,Spring Boot,Microservices,首先为我的英语道歉 我正在尝试使用微服务架构开发应用程序 当我有端点like/restaurant时,我有restaurant模块,我希望该端点对所有人公开 雅马哈酒店(餐厅) 我尝试在方法之前编写@PreAuthorize(“permitAll”)和@PreAuthorize(“permitAll()”)。 我在资源服务器上也尝试了: @Override public void configure(HttpSecurity http) throws Exception { http
@Override
public void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/me")
.authorizeRequests()
.antMatchers("/restaurant-api/restaurants").permitAll()
.anyRequest().authenticated();
}
在授权服务器上使用相同的配置:
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/register").antMatchers("/restaurant-api/restaurants");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/restaurant-api/restaurants/","/restaurant-api/**").permitAll()
.anyRequest().authenticated();
}
举个例子。我尝试了许多URL(/restaurants/**等),但仍然有错误:
{
"error": "unauthorized",
"error_description": "Full authentication is required to access this resource"
}
主体正在正确获取,hasRole正在工作
{
"error": "unauthorized",
"error_description": "Full authentication is required to access this resource"
}