44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package cpdaily
|
||
|
||
import (
|
||
"context"
|
||
"net/http"
|
||
"strings"
|
||
)
|
||
|
||
// ========== 辽宁工程技术大学(lntu)单独适配 ==========
|
||
|
||
// LntuSchoolId 辽宁工程技术大学 tenant id
|
||
const LntuSchoolId = "lntu"
|
||
|
||
// lntuCasLoginEntry 计算辽宁工程技术大学 CAS 登录入口:
|
||
// 网关域 fdm.lntu.edu.cn 的 /iap(school.IdsUrl)会 302 到学校 CAS
|
||
// (authserver.lntu.edu.cn/authserver/login),service 参数携带网关回调
|
||
// /iap/loginSuccess?sessionToken=...;走完 CAS 账密后回调该地址,
|
||
// cookie 才能正确落在 fdm.lntu.edu.cn 域(wec-* 任务接口所在域)。
|
||
func lntuCasLoginEntry(school *SchoolDetailInfo) string {
|
||
if school == nil {
|
||
return ""
|
||
}
|
||
if school.IdsUrl != "" && strings.Contains(school.IdsUrl, "/iap") {
|
||
return school.IdsUrl
|
||
}
|
||
if school.WecloudUrl != "" {
|
||
return strings.TrimSuffix(school.WecloudUrl, "/") + "/iap"
|
||
}
|
||
return school.AmpUrl
|
||
}
|
||
|
||
// lntuCasLogin 辽宁工程技术大学强制走 CAS:
|
||
// 平台接口返回 joinType=CLOUD(IsIap()=true),但网关 /iap/doLogin 不存在(HTTP 405),
|
||
// IAP 账密提交必然失败并报 FAIL_UPNOTMATCH("用户名或密码不匹配",误导用户);
|
||
// 实际链路为 IAP 入口(fdm.lntu.edu.cn/iap)302 → 学校 CAS 账密 → 回调
|
||
// /iap/loginSuccess 建立网关会话。因此强制走 CAS 流程(同许昌学院 xcu 模式)。
|
||
func lntuCasLogin(ctx context.Context, school *SchoolDetailInfo, username, password string) ([]*http.Cookie, *MFAContext, error) {
|
||
lntu := *school
|
||
if entry := lntuCasLoginEntry(school); entry != "" {
|
||
lntu.AmpUrl = entry
|
||
}
|
||
return casLogin(ctx, &lntu, username, password)
|
||
}
|