package com.css.simulation.oauth.server.cofiguration.oauth;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;

import javax.annotation.Resource;

@Configuration
public class MyTokenStore {

    @Resource
    private RedisConnectionFactory redisConnectionFactory;  // 客户端详情服务

    /**
     * 令牌存储
     * <p>
     * （推荐）new RedisTokenStore()：基于 redis
     * （推荐）new JwtTokenStore(accessTokenConverter())：基于 Jwt
     * new InMemoryTokenStore()：基于内存
     * new JwkTokenStore()：基于 Jwk
     * new JdbcTokenStore()：基于 Jdbc
     */
    @Bean
    public TokenStore tokenStore(RedisConnectionFactory redisConnectionFactory) {
        return new RedisTokenStore(redisConnectionFactory);
    }

}
