mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-13 00:57:09 +08:00
refactor: 优化 JustAuth 自动配置(认证模块),使用自定义 JustAuth State 缓存 Redis 实现
This commit is contained in:
@@ -19,7 +19,9 @@ package top.charles7c.continew.starter.auth.justauth.autoconfigure;
|
|||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.zhyd.oauth.cache.AuthStateCache;
|
import me.zhyd.oauth.cache.AuthStateCache;
|
||||||
|
import org.redisson.client.RedisClient;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import top.charles7c.continew.starter.auth.justauth.impl.JustAuthStateCacheRedisImpl;
|
import top.charles7c.continew.starter.auth.justauth.impl.JustAuthStateCacheRedisImpl;
|
||||||
@@ -31,7 +33,7 @@ import top.charles7c.continew.starter.auth.justauth.impl.JustAuthStateCacheRedis
|
|||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AutoConfiguration(after = com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration.class)
|
@AutoConfiguration(before = com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration.class)
|
||||||
@ConditionalOnProperty(prefix = "justauth", value = "enabled", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(prefix = "justauth", value = "enabled", havingValue = "true", matchIfMissing = true)
|
||||||
public class JustAuthAutoConfiguration {
|
public class JustAuthAutoConfiguration {
|
||||||
|
|
||||||
@@ -39,9 +41,12 @@ public class JustAuthAutoConfiguration {
|
|||||||
* 自定义 State 缓存实现
|
* 自定义 State 缓存实现
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(prefix = "justauth.cache", value = "type", havingValue = "custom")
|
@ConditionalOnClass(RedisClient.class)
|
||||||
|
@ConditionalOnProperty(prefix = "justauth.cache", value = "type", havingValue = "redis")
|
||||||
public AuthStateCache authStateCache() {
|
public AuthStateCache authStateCache() {
|
||||||
return new JustAuthStateCacheRedisImpl();
|
JustAuthStateCacheRedisImpl impl = new JustAuthStateCacheRedisImpl();
|
||||||
|
log.debug("[ContiNew Starter] - Auto Configuration 'JustAuth-AuthStateCache-Redis' completed initialization.");
|
||||||
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
|
@@ -22,7 +22,7 @@ import top.charles7c.continew.starter.cache.redisson.util.RedisUtils;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just Auth 自定义 State 缓存实现(Redis)
|
* JustAuth State 缓存 Redis 实现
|
||||||
*
|
*
|
||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
@@ -38,7 +38,7 @@ import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoC
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public abstract class SaTokenDaoConfiguration {
|
abstract class SaTokenDaoConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义持久层实现类-Redis
|
* 自定义持久层实现类-Redis
|
||||||
|
Reference in New Issue
Block a user