From c167669de0cc0f5742669bc7abf705864ff63b1f Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sun, 26 Nov 2023 12:31:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=20JustAuth=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=85=8D=E7=BD=AE=EF=BC=88=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=89=EF=BC=8C=E4=BD=BF=E7=94=A8=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20JustAuth=20State=20=E7=BC=93=E5=AD=98=20Re?= =?UTF-8?q?dis=20=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../autoconfigure/JustAuthAutoConfiguration.java | 11 ++++++++--- .../justauth/impl/JustAuthStateCacheRedisImpl.java | 2 +- .../autoconfigure/SaTokenDaoConfiguration.java | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/autoconfigure/JustAuthAutoConfiguration.java b/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/autoconfigure/JustAuthAutoConfiguration.java index 32b2050a..3477f6b8 100644 --- a/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/autoconfigure/JustAuthAutoConfiguration.java +++ b/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/autoconfigure/JustAuthAutoConfiguration.java @@ -19,7 +19,9 @@ package top.charles7c.continew.starter.auth.justauth.autoconfigure; import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; import me.zhyd.oauth.cache.AuthStateCache; +import org.redisson.client.RedisClient; import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; 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 */ @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) public class JustAuthAutoConfiguration { @@ -39,9 +41,12 @@ public class JustAuthAutoConfiguration { * 自定义 State 缓存实现 */ @Bean - @ConditionalOnProperty(prefix = "justauth.cache", value = "type", havingValue = "custom") + @ConditionalOnClass(RedisClient.class) + @ConditionalOnProperty(prefix = "justauth.cache", value = "type", havingValue = "redis") public AuthStateCache authStateCache() { - return new JustAuthStateCacheRedisImpl(); + JustAuthStateCacheRedisImpl impl = new JustAuthStateCacheRedisImpl(); + log.debug("[ContiNew Starter] - Auto Configuration 'JustAuth-AuthStateCache-Redis' completed initialization."); + return impl; } @PostConstruct diff --git a/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/impl/JustAuthStateCacheRedisImpl.java b/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/impl/JustAuthStateCacheRedisImpl.java index f759d558..4676cfe4 100644 --- a/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/impl/JustAuthStateCacheRedisImpl.java +++ b/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/impl/JustAuthStateCacheRedisImpl.java @@ -22,7 +22,7 @@ import top.charles7c.continew.starter.cache.redisson.util.RedisUtils; import java.time.Duration; /** - * Just Auth 自定义 State 缓存实现(Redis) + * JustAuth State 缓存 Redis 实现 * * @author Charles7c * @since 1.0.0 diff --git a/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenDaoConfiguration.java b/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenDaoConfiguration.java index aac7b864..4a41672c 100644 --- a/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenDaoConfiguration.java +++ b/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenDaoConfiguration.java @@ -38,7 +38,7 @@ import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoC */ @Slf4j @NoArgsConstructor(access = AccessLevel.PRIVATE) -public abstract class SaTokenDaoConfiguration { +abstract class SaTokenDaoConfiguration { /** * 自定义持久层实现类-Redis