在以前版本的OAuth2中,可以通过将自定义令牌Granter添加到< authorization-server>中的xml配置来添加它.元件.
我想知道如何使用AuthorizationServerConfigurerAdapter使用Java Config扩展授权服务器,而不会丢失包含隐式,客户端凭据,刷新令牌和授权代码授权类型的默认配置.
首次尝试使用@Component创建TokenGranter:
@Component("customTokenGranter")
public class CustomTokenGranter {
//implementation
}
这导致依赖性解决异常,因为构造Granter所需的tokenServices无法自动装配.
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception
{
endpoints
.tokenGranter(new CustomTokenGranter(endpoints.getTokenServices(),endpoints.getClientDetailsService(),endpoints.getoAuth2RequestFactory()));
}
最佳答案
您还需要添加默认值,例如使用CompositetokenGranter:
ListetokenGranter(tokenGranters);
endpoints.tokenGranter(tokenGranter);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。