Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
陈绍鑫 2025-06-30 17:56:36 +08:00
commit e552b89e00
1 changed files with 24 additions and 31 deletions

View File

@ -37,6 +37,7 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
*/ */
@Override @Override
public void callTrdSSOLogin(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String s) { public void callTrdSSOLogin(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String s) {
logger.info(String.format("callTrdSSOLogin→httpServletRequest%s", httpServletRequest));
String ip; String ip;
String client; String client;
@ -52,29 +53,16 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
client = CLIENT_ID; client = CLIENT_ID;
secret = CLIENT_SECRET; secret = CLIENT_SECRET;
} }
String ssourl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html"; logger.info(String.format("callTrdSSOLogin→queryUrl%s", queryUrl));
//图标登录到首页 String ssourl;
if (!queryUrl.contains("yzjShareOpen.do")) { try {
try { //非待办登录到首页
if (!queryUrl.contains("wf_approvalpage")) {
//认证中心的登录地址
logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s", ip, client, secret, s));
//重定向的统一认证的地址 获取授权码 //重定向的统一认证的地址 获取授权码
ssourl = String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&sessionKeep=true&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, s); ip, client, s);
logger.info(String.format("重定向地址→sendRedirect%s", ssourl));
httpServletResponse.sendRedirect(ssourl);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8));
// String skIp = httpServletRequest.getRemo
String skUrl = RevProxyUtil.getURLContextPath(httpServletRequest);
logger.info("getURLContextPath" + skUrl);
String redirect = skIP + "/index.html?param=" + queryUrl;
logger.info("skip" + skUrl);
//认证中心的登录地址
logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s", ip, client, secret, s));
try {
if (httpServletRequest.getRequestURI().contains("/auth/logout.do")) { if (httpServletRequest.getRequestURI().contains("/auth/logout.do")) {
String userName = UserServiceHelper.getCurrentUser("name").getString("name"); String userName = UserServiceHelper.getCurrentUser("name").getString("name");
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion"); DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
@ -83,16 +71,22 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
if (sessionId != null) { if (sessionId != null) {
AuthService.logout(ip, sessionId); AuthService.logout(ip, sessionId);
} }
} else { ssourl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html";
//重定向的统一认证的地址 获取授权码
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));
} }
httpServletResponse.sendRedirect(ssourl); } else {
} catch (IOException e) { queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8));
throw new RuntimeException(e); String skUrl = RevProxyUtil.getURLContextPath(httpServletRequest);
logger.info("callTrdSSOLogin→getURLContextPath" + skUrl);
String redirect = skIP + "/index.html?param=" + queryUrl;
logger.info("callTrdSSOLogin→skip" + redirect);
//重定向的统一认证的地址 获取授权码
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("callTrdSSOLogin→→sendRedirect%s", ssourl));
httpServletResponse.sendRedirect(ssourl);
} catch (IOException e) {
throw new RuntimeException(e);
} }
} }
@ -120,16 +114,15 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
String code = httpServletRequest.getParameter("code"); String code = httpServletRequest.getParameter("code");
logger.info(String.format("getTrdSSOAuth→授权码code%s", code)); logger.info(String.format("getTrdSSOAuth→授权码code%s", code));
if (StringUtils.isEmpty(code)) { if (StringUtils.isEmpty(code)) {
logger.error("getTrdSSOAuth→授权码code为空");
result.setSucess(false); result.setSucess(false);
return result; return result;
} }
//调用EOSS获取token接口 //调用EOSS获取token接口
String access_token = AuthService.accessToken(code, ip, client, secret); String access_token = AuthService.accessToken(code, ip, client, secret);
logger.info(String.format("accessToken返回数据%s", access_token)); logger.info(String.format("getTrdSSOAuth→accessToken返回数据%s", access_token));
//调用EOSS获取用户信息接口 //调用EOSS获取用户信息接口
String user = AuthService.getUserInfo(access_token, ip, client, secret); String user = AuthService.getUserInfo(access_token, ip, client, secret);
logger.info(String.format("getUserInfo返回数据%s", user)); logger.info(String.format("getTrdSSOAuth→getUserInfo返回数据%s", user));
String param = httpServletRequest.getParameter("param"); String param = httpServletRequest.getParameter("param");
//解码 //解码
if (param != null) { if (param != null) {