【发布时间】:2020-10-02 09:12:26
【问题描述】:
在学习了关于 Maven Spring Boot 中的微服务和 OAuth2 的教程之后,我遇到了一个问题。我想从身份验证中排除请求,因此可以获得未经授权的数据。这只似乎不适用于我这样做的方式。有人可以帮我解决这个问题吗?
我尝试了什么:
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.requestMatcher(new RequestHeaderRequestMatcher("Authorization"))
.authorizeRequests()
.antMatchers("/**").authenticated()
.and()
.authorizeRequests()
.andMatchers(HttpMethod.GET, "/beers").permitAll();
}
}
当我尝试执行请求时,我必须进行身份验证。我该如何解决?
spring-security-oauth2-autoconfigure: 2.1.1.RELEASE
【问题讨论】:
标签: java spring-boot spring-security oauth