Skip to content

Commit 4cb510e

Browse files
author
Jimmy Xu
committed
add auth server refresh_token support
1 parent 24c1e73 commit 4cb510e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

auth-server/src/main/java/com/newtouch/cloud/demo/auth/config/OAuthSecurityConfig.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.newtouch.cloud.demo.auth.config;
22

33
import org.springframework.beans.factory.ObjectProvider;
4+
import org.springframework.beans.factory.annotation.Qualifier;
45
import org.springframework.boot.autoconfigure.security.oauth2.authserver.AuthorizationServerProperties;
56
import org.springframework.boot.autoconfigure.security.oauth2.authserver.AuthorizationServerTokenServicesConfiguration;
67
import org.springframework.boot.context.properties.EnableConfigurationProperties;
78
import org.springframework.context.annotation.Configuration;
89
import org.springframework.context.annotation.Import;
910
import org.springframework.security.authentication.AuthenticationManager;
1011
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
12+
import org.springframework.security.core.userdetails.UserDetailsService;
1113
import org.springframework.security.crypto.password.PasswordEncoder;
1214
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
1315
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
@@ -31,17 +33,21 @@ public class OAuthSecurityConfig extends AuthorizationServerConfigurerAdapter {
3133
private final TokenStore tokenStore;
3234
private final AccessTokenConverter tokenConverter;
3335
private AuthorizationServerProperties properties;
36+
private UserDetailsService userDetailsService;
3437

3538
public OAuthSecurityConfig(AuthenticationConfiguration configuration, PasswordEncoder passwordEncoder,
3639
DataSource datasource,
3740
ObjectProvider<TokenStore> tokenStore,
38-
ObjectProvider<AccessTokenConverter> tokenConverter, AuthorizationServerProperties properties) throws Exception {
41+
ObjectProvider<AccessTokenConverter> tokenConverter,
42+
AuthorizationServerProperties properties,
43+
@Qualifier("newtouchUserDetailsService") UserDetailsService userDetailsService) throws Exception {
3944
this.authenticationManager = configuration.getAuthenticationManager();
4045
this.passwordEncoder = passwordEncoder;
4146
this.dataSource = datasource;
4247
this.tokenStore = tokenStore.getIfAvailable();
4348
this.tokenConverter = tokenConverter.getIfAvailable();
4449
this.properties = properties;
50+
this.userDetailsService = userDetailsService;
4551
}
4652

4753
@Override
@@ -70,6 +76,7 @@ public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
7076
.tokenStore(tokenStore)
7177
.accessTokenConverter(tokenConverter)
7278
.authenticationManager(authenticationManager)
79+
.userDetailsService(userDetailsService)
7380
.reuseRefreshTokens(false);// support password flow
7481
}
7582
}

0 commit comments

Comments
 (0)