1.版本
spring-security-oauth2-authorization-server 0.2.3
spring-boot 2.6.6
2.概述
spring-authorization-server中实现的oauth2标准中已经不支持自定义资源拥有者模式,但是项目从之前spring-seucirty-oauth2内置的升级到最新的授权服务器或者需要资源拥有者模式,就不要扩展
3.分析
官方源码的测试代码中给的示例初始化spring security的安全配置基本如下
protected void configure(HttpSecurity http) throws Exception {
authorizationServerHttpSecurityConfigurer.configure(http);
OAuth2AuthorizationServerConfigurer<HttpSecurity> authorizationServerConfigurer =
new OAuth2AuthorizationServerConfigurer<>();
RequestMatcher requestMatcher = new OrRequestMatcher(authorizationServerConfigurer.getEndpointsMatcher(),
new AntPathRequestMatcher("/oauth2/consent"),
loginRequestMatcher);
http
.requestMatcher(requestMatcher)
.authorizeRequests(authorizeRequests ->
authorizeRequests.anyRequest().authenticated()