Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.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[Cloud]Oauth2排除微服务上的url_Java_Spring Boot_Microservices - Fatal编程技术网

Java Spring[Cloud]Oauth2排除微服务上的url

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

首先为我的英语道歉

我正在尝试使用微服务架构开发应用程序

当我有端点like/restaurant时,我有restaurant模块,我希望该端点对所有人公开

雅马哈酒店(餐厅)

我尝试在方法之前编写@PreAuthorize(“permitAll”)和@PreAuthorize(“permitAll()”)。 我在资源服务器上也尝试了:

@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"
}