From 18e919bde3d925ee76fe29c7a6621c2716b1e4e4 Mon Sep 17 00:00:00 2001
From: baoshiwei <baoshiwei@shlanbao.cn>
Date: 星期五, 21 三月 2025 09:43:31 +0800
Subject: [PATCH] feat(social): 添加 Keycloak社交登录支持

---
 ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java
index f7f2392..0b6ec20 100644
--- a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java
+++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java
@@ -1,18 +1,17 @@
 package org.dromara.common.social.utils;
 
-import jakarta.annotation.PostConstruct;
+import lombok.AllArgsConstructor;
 import me.zhyd.oauth.cache.AuthStateCache;
+import org.dromara.common.core.constant.GlobalConstants;
 import org.dromara.common.redis.utils.RedisUtils;
-import org.dromara.common.social.config.properties.SocialProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.ValueOperations;
 
 import java.time.Duration;
 
+/**
+ * 鎺堟潈鐘舵�佺紦瀛�
+ */
+@AllArgsConstructor
 public class AuthRedisStateCache implements AuthStateCache {
-
-    private SocialProperties socialProperties;
 
     /**
      * 瀛樺叆缂撳瓨
@@ -22,8 +21,8 @@
      */
     @Override
     public void cache(String key, String value) {
-        // TODO: 鑷畾涔夊瓨鍏ョ紦瀛�
-        RedisUtils.setCacheObject(key, value, Duration.ofMillis(socialProperties.getTimeout()));
+        // 鎺堟潈瓒呮椂鏃堕棿 榛樿涓夊垎閽�
+        RedisUtils.setCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key, value, Duration.ofMinutes(3));
     }
 
     /**
@@ -35,8 +34,7 @@
      */
     @Override
     public void cache(String key, String value, long timeout) {
-        // TODO: 鑷畾涔夊瓨鍏ョ紦瀛�
-        RedisUtils.setCacheObject(key, value, Duration.ofMillis(timeout));
+        RedisUtils.setCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key, value, Duration.ofMillis(timeout));
     }
 
     /**
@@ -47,8 +45,7 @@
      */
     @Override
     public String get(String key) {
-        // TODO: 鑷畾涔夎幏鍙栫紦瀛樺唴瀹�
-        return RedisUtils.getCacheObject(key);
+        return RedisUtils.getCacheObject(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key);
     }
 
     /**
@@ -59,7 +56,6 @@
      */
     @Override
     public boolean containsKey(String key) {
-        // TODO: 鑷畾涔夊垽鏂璳ey鏄惁瀛樺湪
-        return RedisUtils.hasKey(key);
+        return RedisUtils.hasKey(GlobalConstants.SOCIAL_AUTH_CODE_KEY + key);
     }
 }

--
Gitblit v1.9.3