use of org.shanzhaozhen.authorize.config.oauth2.authentication.OAuth2ResourceOwnerPasswordAuthenticationProvider in project best-cloud by shanzhaozhen.
the class AuthorizationServerConfig method addCustomOAuth2ResourceOwnerPasswordAuthenticationProvider.
/**
* 基于默认授权服务器设置中追加 password 模式
* @param http
*/
private void addCustomOAuth2ResourceOwnerPasswordAuthenticationProvider(HttpSecurity http) {
AuthenticationManager authenticationManager = http.getSharedObject(AuthenticationManager.class);
// 弃用JwtEncoder和关联的类以准备在0.3.0发布中删除(请参阅gh-594)。
// 该0.3.0版本将使用Spring Security 5.6JwtEncoder中引入的。
JwtEncoder jwtEncoder = OAuth2ConfigurerUtils.getJwtEncoder(http);
OAuth2TokenCustomizer<JwtEncodingContext> jwtCustomizer = OAuth2ConfigurerUtils.getJwtCustomizer(http);
OAuth2ResourceOwnerPasswordAuthenticationProvider resourceOwnerPasswordAuthenticationProvider = new OAuth2ResourceOwnerPasswordAuthenticationProvider(authenticationManager, OAuth2ConfigurerUtils.getAuthorizationService(http), jwtEncoder);
if (jwtCustomizer != null) {
resourceOwnerPasswordAuthenticationProvider.setJwtCustomizer(jwtCustomizer);
}
http.authenticationProvider(resourceOwnerPasswordAuthenticationProvider);
}
Aggregations