|
|
@@ -4,6 +4,7 @@ import com.unissoft.service.MyClientDetailsService;
|
|
4
|
4
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
5
|
5
|
import org.springframework.context.annotation.Bean;
|
|
6
|
6
|
import org.springframework.context.annotation.Configuration;
|
|
|
7
|
+import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
7
|
8
|
import org.springframework.http.HttpMethod;
|
|
8
|
9
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
9
|
10
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
@@ -19,6 +20,7 @@ import org.springframework.security.oauth2.provider.token.TokenEnhancerChain;
|
|
19
|
20
|
import org.springframework.security.oauth2.provider.token.TokenStore;
|
|
20
|
21
|
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
|
|
21
|
22
|
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
|
|
23
|
+import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
|
|
22
|
24
|
|
|
23
|
25
|
import javax.sql.DataSource;
|
|
24
|
26
|
import java.util.Arrays;
|
|
|
@@ -37,8 +39,10 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
|
37
|
39
|
*/
|
|
38
|
40
|
@Autowired
|
|
39
|
41
|
private AuthenticationManager authenticationManager;
|
|
|
42
|
+// @Autowired
|
|
|
43
|
+// private DataSource dataSource;
|
|
40
|
44
|
@Autowired
|
|
41
|
|
- private DataSource dataSource;
|
|
|
45
|
+ private RedisConnectionFactory redisConnectionFactory;
|
|
42
|
46
|
@Autowired
|
|
43
|
47
|
private MyClientDetailsService myClientDetailsService;
|
|
44
|
48
|
|
|
|
@@ -71,7 +75,10 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
|
71
|
75
|
|
|
72
|
76
|
@Bean
|
|
73
|
77
|
public TokenStore tokenStore() {
|
|
74
|
|
- return new JdbcTokenStore(dataSource);//存数据库
|
|
|
78
|
+ // 存入数据库
|
|
|
79
|
+// return new JdbcTokenStore(dataSource);
|
|
|
80
|
+ // 存入redis
|
|
|
81
|
+ return new RedisTokenStore(redisConnectionFactory);
|
|
75
|
82
|
}
|
|
76
|
83
|
|
|
77
|
84
|
// 配置授权服务器端点
|