CreateStore creates a token store based on the provided configuration
(config *Config)
| 59 | |
| 60 | // CreateStore creates a token store based on the provided configuration |
| 61 | func (f *Factory) CreateStore(config *Config) (core.TokenStore, error) { |
| 62 | if config == nil { |
| 63 | config = DefaultConfig() |
| 64 | } |
| 65 | |
| 66 | switch config.Type { |
| 67 | case MemoryStore: |
| 68 | return NewInMemoryRefreshTokenStore(), nil |
| 69 | |
| 70 | case RedisStore: |
| 71 | redisConfig := config.Redis |
| 72 | if redisConfig == nil { |
| 73 | redisConfig = DefaultRedisConfig() |
| 74 | } |
| 75 | return NewRedisRefreshTokenStore(redisConfig) |
| 76 | |
| 77 | default: |
| 78 | return nil, fmt.Errorf("unsupported store type: %s", config.Type) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | // Convenience functions for creating stores |
| 83 |