SSO 0.3 登出

This commit is contained in:
李靖 2024-05-27 15:04:33 +08:00
parent e79705cb98
commit 5f4fde156d
1 changed files with 17 additions and 5 deletions

View File

@ -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")