From ce482add9cc03ee7967232af7553536361b3c81c Mon Sep 17 00:00:00 2001 From: monkeyk7 Date: Thu, 4 Jul 2019 19:56:37 +0800 Subject: [PATCH] Add redis config --- .../monkeyk/sos/config/OAuth2ServerConfiguration.java | 9 ++++++++- src/main/resources/application.properties | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java b/src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java index 4080d76..a1bd554 100644 --- a/src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java +++ b/src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java @@ -7,6 +7,7 @@ import com.monkeyk.sos.service.UserService; import com.monkeyk.sos.web.oauth.OauthUserApprovalHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; @@ -131,6 +132,10 @@ public class OAuth2ServerConfiguration { private AuthenticationManager authenticationManager; + @Value("${spring.application.name:sos}") + private String applicationName; + + @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { @@ -151,7 +156,9 @@ public class OAuth2ServerConfiguration { */ @Bean public TokenStore tokenStore(RedisConnectionFactory connectionFactory) { - return new RedisTokenStore(connectionFactory); + final RedisTokenStore redisTokenStore = new RedisTokenStore(connectionFactory); + redisTokenStore.setPrefix(applicationName); + return redisTokenStore; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a832593..ed0cf47 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -34,7 +34,7 @@ spring.jmx.enabled=false # spring.redis.host=localhost spring.redis.port=6379 -spring.redis.database=2 +spring.redis.database=0 spring.redis.password= #spring.redis.timeout=2000 #spring.redis.ssl=false