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
public void callTrdSSOLogin(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String s) {
logger.info(String.format("callTrdSSOLogin→httpServletRequest%s", httpServletRequest));
String ip;
String client;
@ -52,29 +53,16 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
client = CLIENT_ID;
secret = CLIENT_SECRET;
}
String ssourl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html";
//图标登录到首页
if (!queryUrl.contains("yzjShareOpen.do")) {
try {
logger.info(String.format("callTrdSSOLogin→queryUrl%s", queryUrl));
String ssourl;
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",
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")) {
String userName = UserServiceHelper.getCurrentUser("name").getString("name");
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
@ -83,16 +71,22 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
if (sessionId != null) {
AuthService.logout(ip, sessionId);
}
} else {
//重定向的统一认证的地址 获取授权码
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));
ssourl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html";
}
httpServletResponse.sendRedirect(ssourl);
} catch (IOException e) {
throw new RuntimeException(e);
} else {
queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8));
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");
logger.info(String.format("getTrdSSOAuth→授权码code%s", code));
if (StringUtils.isEmpty(code)) {
logger.error("getTrdSSOAuth→授权码code为空");
result.setSucess(false);
return result;
}
//调用EOSS获取token接口
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获取用户信息接口
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");
//解码
if (param != null) {