diff --git a/README.md b/README.md
index ebf8579..362b605 100644
--- a/README.md
+++ b/README.md
@@ -165,7 +165,8 @@ Base on Spring-Boot
增加使用代码生成AccessToken功能
- 增加将AccessToken存入Redis的配置参考
+ 增加将AccessToken存入Redis的配置参考
+ 升级Spring Security OAuth版本为2.3.4.RELEASE
修改ROLE的错误配置
Use spring-boot 2.0.2.RELEASE
diff --git a/pom.xml b/pom.xml
index f5471a7..3d15f7e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
UTF-8
1.8
- 2.3.0.RELEASE
+ 2.3.4.RELEASE
false
@@ -66,6 +66,11 @@
${spring.security.oauth.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
org.springframework.security
diff --git a/src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java b/src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java
index df6d17e..d6fc674 100644
--- a/src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java
+++ b/src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
@@ -27,7 +28,7 @@ import org.springframework.security.oauth2.provider.code.AuthorizationCodeServic
import org.springframework.security.oauth2.provider.code.JdbcAuthorizationCodeServices;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory;
import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
+import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import javax.sql.DataSource;
@@ -136,9 +137,23 @@ public class OAuth2ServerConfiguration {
}
+ /*
+ * JDBC TokenStore
+ */
+// @Bean
+// public TokenStore tokenStore(DataSource dataSource) {
+// return new JdbcTokenStore(dataSource);
+// }
+
+ /*
+ * Redis TokenStore
+ */
@Bean
- public TokenStore tokenStore(DataSource dataSource) {
- return new JdbcTokenStore(dataSource);
+ public TokenStore tokenStore(RedisConnectionFactory connectionFactory) {
+ final RedisTokenStore redisTokenStore = new RedisTokenStore(connectionFactory);
+ //prefix
+ redisTokenStore.setPrefix(RESOURCE_ID);
+ return redisTokenStore;
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 3b9130d..ed0cf47 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -29,3 +29,13 @@ logging.level.root=INFO
#
# Support deploy to a servlet-container
spring.jmx.enabled=false
+#
+# Redis
+#
+spring.redis.host=localhost
+spring.redis.port=6379
+spring.redis.database=0
+spring.redis.password=
+#spring.redis.timeout=2000
+#spring.redis.ssl=false
+