1
1
package com .newtouch .cloud .demo .auth .config ;
2
2
3
3
import org .springframework .beans .factory .ObjectProvider ;
4
+ import org .springframework .beans .factory .annotation .Qualifier ;
4
5
import org .springframework .boot .autoconfigure .security .oauth2 .authserver .AuthorizationServerProperties ;
5
6
import org .springframework .boot .autoconfigure .security .oauth2 .authserver .AuthorizationServerTokenServicesConfiguration ;
6
7
import org .springframework .boot .context .properties .EnableConfigurationProperties ;
7
8
import org .springframework .context .annotation .Configuration ;
8
9
import org .springframework .context .annotation .Import ;
9
10
import org .springframework .security .authentication .AuthenticationManager ;
10
11
import org .springframework .security .config .annotation .authentication .configuration .AuthenticationConfiguration ;
12
+ import org .springframework .security .core .userdetails .UserDetailsService ;
11
13
import org .springframework .security .crypto .password .PasswordEncoder ;
12
14
import org .springframework .security .oauth2 .config .annotation .configurers .ClientDetailsServiceConfigurer ;
13
15
import org .springframework .security .oauth2 .config .annotation .web .configuration .AuthorizationServerConfigurerAdapter ;
@@ -31,17 +33,21 @@ public class OAuthSecurityConfig extends AuthorizationServerConfigurerAdapter {
31
33
private final TokenStore tokenStore ;
32
34
private final AccessTokenConverter tokenConverter ;
33
35
private AuthorizationServerProperties properties ;
36
+ private UserDetailsService userDetailsService ;
34
37
35
38
public OAuthSecurityConfig (AuthenticationConfiguration configuration , PasswordEncoder passwordEncoder ,
36
39
DataSource datasource ,
37
40
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 {
39
44
this .authenticationManager = configuration .getAuthenticationManager ();
40
45
this .passwordEncoder = passwordEncoder ;
41
46
this .dataSource = datasource ;
42
47
this .tokenStore = tokenStore .getIfAvailable ();
43
48
this .tokenConverter = tokenConverter .getIfAvailable ();
44
49
this .properties = properties ;
50
+ this .userDetailsService = userDetailsService ;
45
51
}
46
52
47
53
@ Override
@@ -70,6 +76,7 @@ public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
70
76
.tokenStore (tokenStore )
71
77
.accessTokenConverter (tokenConverter )
72
78
.authenticationManager (authenticationManager )
79
+ .userDetailsService (userDetailsService )
73
80
.reuseRefreshTokens (false );// support password flow
74
81
}
75
82
}
0 commit comments