From 5f4fde156dbb179f6b2143fb70d2442857e8a3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=96?= Date: Mon, 27 May 2024 15:04:33 +0800 Subject: [PATCH] =?UTF-8?q?SSO=200.3=20=E7=99=BB=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/shkd/plugin/SSOLoginPugin.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/shkd-cosmic-debug/src/main/java/shkd/plugin/SSOLoginPugin.java b/shkd-cosmic-debug/src/main/java/shkd/plugin/SSOLoginPugin.java index a1dfe00..7429ec1 100644 --- a/shkd-cosmic-debug/src/main/java/shkd/plugin/SSOLoginPugin.java +++ b/shkd-cosmic-debug/src/main/java/shkd/plugin/SSOLoginPugin.java @@ -48,7 +48,8 @@ public class SSOLoginPugin implements ThirdSSOAuthHandler { String urlToRedirectTo = ""; String path = request.getRequestURI(); if (path.contains("/auth/logout.do")) { - urlToRedirectTo = StringUtils.getPathString(this.casSeverLoginUrl) + "logout?service=" + RevProxyUtil.getURLContextPath(request); + urlToRedirectTo = initCasLogoutUrl() + "?service=" + service; + // urlToRedirectTo = StringUtils.getPathString(this.casSeverLoginUrl) + "logout?service=" + RevProxyUtil.getURLContextPath(request); } else { String serviceUrl = this.constructServiceUrl(request, response); logger.debug(String.format("Constructed service url: %s", serviceUrl)); @@ -74,6 +75,16 @@ public class SSOLoginPugin implements ThirdSSOAuthHandler { return configLoginUrl; } + public String initCasLogoutUrl() { + String configLogoutUrl = System.getProperty("cas.sso.ca10.logouturl"); + if (configLogoutUrl == null) { + configLogoutUrl = "https://oa-uat.elmleaf.com.cn/sso/logout"; + logger.error("没有配置 sso 登录cas.sso.ca10.logouturl"); + } + + return configLogoutUrl; + } + // 该方法实现第三发插件认证及认证结果的返回 public UserAuthResult getTrdSSOAuth(HttpServletRequest request, HttpServletResponse response) { UserAuthResult result = new UserAuthResult(); @@ -88,15 +99,16 @@ public class SSOLoginPugin implements ThirdSSOAuthHandler { if (CommonUtils.isNotBlank(ticket)) { try { logger.info(String.format("Attempting to validate ticket: %s", ticket)); - logger.debug(String.format("Attempting to validate ticket: %s", ticket)); + //logger.debug(String.format("Attempting to validate ticket: %s", ticket)); String service2 = this.constructServiceUrl(request, response); logger.info(String.format("Attempting to validate service2: %s", service2)); - logger.debug(String.format("Attempting to validate service2: %s", service2)); - String tempXml = HttpRequest.post("https://oa-uat.elmleaf.com.cn/sso/proxyValidate") + //logger.debug(String.format("Attempting to validate service2: %s", service2)); + // "https://oa-uat.elmleaf.com.cn/sso/proxyValidate" + String tempXml = HttpRequest.post("http://10.157.226.9:8088/sso/proxyValidate") .contentType("application/x-www-form-urlencoded") .form("ticket",ticket) .form("service", service2).execute().body(); - + logger.info(String.format("Attempting to validate tempXml: %s", tempXml)); if (tempXml != null) { JSONObject user = XML.toJSONObject(tempXml); String username = user.getJSONObject("cas:serviceResponse")