diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/SSOPluginLogin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/SSOPluginLogin.java index d2e3617..a9ac879 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/SSOPluginLogin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/SSOPluginLogin.java @@ -9,6 +9,7 @@ import kd.bos.login.thirdauth.ThirdSSOAuthHandler; import kd.bos.login.thirdauth.UserAuthResult; import kd.bos.login.thirdauth.UserProperType; import kd.bos.servicehelper.user.UserServiceHelper; +import kd.bos.util.RevProxyUtil; import org.apache.commons.lang3.StringUtils; import javax.servlet.http.*; @@ -27,7 +28,7 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler { private final String CLIENT_ID2 = System.getProperty("scnyfz-clientKey"); private final String CLIENT_SECRET2 = System.getProperty("scnyfz-scict"); - private final String EOSS_IP2 = System.getProperty("scnyfz-ip"); + private final String EOSS_IP2 = System.getProperty("scnyfz-ip2"); /** * 方法实现用户没有登录的时候跳转认证中心的登录地址 @@ -57,10 +58,11 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler { }else{ queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8)); // String skIp = httpServletRequest.getRemoteAddr(); - String skUrl = httpServletRequest.getRequestURL().toString(); - skUrl = skUrl.substring(0, skUrl.indexOf("ierp")); +// String skUrl = httpServletRequest.getRequestURL().toString(); +// skUrl = skUrl.substring(0, skUrl.indexOf("ierp")); + String skUrl = RevProxyUtil.getURLContextPath(httpServletRequest); logger.info("获取地址:"+skUrl); - String redirect = "http://10.1.7.83:8022/"+"ierp/index.html?param="+queryUrl; + String redirect = skUrl+"index.html?param="+queryUrl; //认证中心的登录地址 logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s", ip, client, secret, s)); String ssourl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html"; @@ -76,7 +78,7 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler { } } else { //重定向的统一认证的地址 获取授权码 - ssourl = String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&sessionKeep=false&authType=0&redirect_uri=%s", + ssourl = String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&sessionKeep=true&authType=0&redirect_uri=%s", ip, client, redirect); logger.info(String.format("重定向地址→sendRedirect:%s", ssourl)); } @@ -124,8 +126,8 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler { } -// //获取返回的 sessionId -// String sessionId = httpServletRequest.getParameter("sessionId"); + //获取返回的 sessionId + String sessionId = httpServletRequest.getParameter("sessionId"); // String userName = httpServletRequest.getParameter("userName"); // if (userName != null) { // userName = userName.replace(" ", "+"); // 将空格替换为 + 号 @@ -154,9 +156,9 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler { result.setUser(user); result.setSucess(true); logger.info("SSO用户登录成功,进入苍穹系统"); -// String userKey = "user_sessionId_" + user; // 构造一个唯一的键 -// DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion"); -// cache.put(userKey, sessionId);//将自定义参数加入缓存 + String userKey = "user_sessionId_" + user; // 构造一个唯一的键 + DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion"); + cache.put(userKey, sessionId);//将自定义参数加入缓存 } } catch (Exception e) { throw new KDBizException("获取用户信息接口异常,SSO用户登录失败!" + e);