Compare commits

..

No commits in common. "21c09d2be3065f5ac60d0187c8cead523f6c0bdd" and "e22dd6356a8f4caf840a769887bcaea7e3b30849" have entirely different histories.

2 changed files with 4 additions and 37 deletions

View File

@ -83,15 +83,4 @@ public class AuthService {
} }
return null; return null;
} }
public static void logout(String eoss_ip,String session_id){
String url = String.format("%s/sso2/authCenter/logout", eoss_ip);
// 构建 URL添加查询参数
String urlWithParams = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("sessionId", session_id)
.toUriString(); // 生成带参数的完整 URL
ResponseEntity<String> response = restTemplate.exchange(urlWithParams, HttpMethod.GET,null, String.class);
logger.info(String.format("logout→返回结果:%s",response.getBody()));
}
} }

View File

@ -2,18 +2,12 @@ package shkd.sys.sys.eoss;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import kd.bos.cache.CacheFactory;
import kd.bos.cache.DistributeSessionlessCache;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
import kd.bos.login.thirdauth.ThirdSSOAuthHandler; import kd.bos.login.thirdauth.ThirdSSOAuthHandler;
import kd.bos.login.thirdauth.UserAuthResult; import kd.bos.login.thirdauth.UserAuthResult;
import kd.bos.login.thirdauth.UserProperType; import kd.bos.login.thirdauth.UserProperType;
import kd.bos.servicehelper.user.UserServiceHelper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -41,18 +35,9 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
//认证中心的登录地址 //认证中心的登录地址
logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s",EOSS_IP,CLIENT_ID,CLIENT_SECRET,s)); logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s",EOSS_IP,CLIENT_ID,CLIENT_SECRET,s));
try { try {
if (httpServletRequest.getRequestURI().contains("/auth/logout.do")){ //重定向的统一认证的地址
String userName = UserServiceHelper.getCurrentUser("name").getString("name");
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
String userKey = "user_sessionId_" + userName; // 构造一个唯一的键
String sessionId = cache.get(userKey);
if (sessionId != null) {
AuthService.logout(EOSS_IP, sessionId);
}
}
/** /**
*重定向的统一认证的地址 获取授权码 * 获取授权码
*/ */
String ssourl=String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&authType=0&redirect_uri=%s", String ssourl=String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&authType=0&redirect_uri=%s",
EOSS_IP,CLIENT_ID,s); EOSS_IP,CLIENT_ID,s);
@ -76,11 +61,9 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
UserAuthResult result=new UserAuthResult(); UserAuthResult result=new UserAuthResult();
//获取返回的授权码 //获取返回的授权码
String code = httpServletRequest.getParameter("code"); String code = httpServletRequest.getParameter("code");
//获取返回的 sessionId logger.info(String.format("getTrdSSOAuth→code%s",code));
String sessionId = httpServletRequest.getParameter("sessionId");
logger.info(String.format("getTrdSSOAuth→授权码code%s",code));
if (StringUtils.isEmpty(code)){ if (StringUtils.isEmpty(code)){
logger.error("getTrdSSOAuth→授权码code为空"); logger.error("getTrdSSOAuth→code为空");
result.setSucess(false); result.setSucess(false);
}else { }else {
try { try {
@ -98,11 +81,6 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
result.setUser(user); result.setUser(user);
result.setSucess(true); result.setSucess(true);
logger.info("SSO用户登录成功进入苍穹系统"); logger.info("SSO用户登录成功进入苍穹系统");
String userKey = "user_sessionId_" + user; // 构造一个唯一的键
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
cache.put(userKey,sessionId);//将自定义参数加入缓存
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();