前端 bschlogin.js 的 getQueryVariable 未对 query value 做 decodeURIComponent, 会把浏览器地址栏里百分号编码态的 service(http%3A%2F%2F...) 原样 POST 给后端, 导致 WebApplicationServiceFactory.createService 拿到的仍是编码串,CAS 服务注册表 正则 ^(https|imaps|http)://.* 匹配不到而抛 UnauthorizedServiceException (带 service 登录报"建立会话失败")。改为在后端 login() 入口统一解码,方便后续扩展。
This commit is contained in:
@@ -37,6 +37,7 @@ import javax.servlet.http.HttpSession;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.URLDecoder;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -116,6 +117,19 @@ public class LoginController {
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
||||
// 前端未对 service 做 URL 解码(bschlogin.js getQueryVariable 直接 slice 不做 decodeURIComponent),
|
||||
// 会把浏览器地址栏里百分号编码态的 service(http%3A%2F%2F...)原样 POST 给后端,导致
|
||||
// WebApplicationServiceFactory.createService 拿到的仍是编码串,CAS 服务注册表正则
|
||||
// ^(https|imaps|http)://.* 匹配不到而抛 UnauthorizedServiceException(带 service 登录报“建立会话失败”)。
|
||||
// 统一在此把 service 解码成真实 URL(http://...)并向后透传解码值,方便后续其它逻辑直接读取。
|
||||
if (service != null && !service.trim().isEmpty()) {
|
||||
try {
|
||||
service = URLDecoder.decode(service, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
logger.warn("service 参数 URL 解码失败,按原值使用: {}", service);
|
||||
}
|
||||
}
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user