Browse Source

Add redis config

pull/2/head
monkeyk7 5 years ago
parent
commit
ce482add9c
  1. 9
      src/main/java/com/monkeyk/sos/config/OAuth2ServerConfiguration.java
  2. 2
      src/main/resources/application.properties

9
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;
}

2
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

Loading…
Cancel
Save