feat(sso): MaxKey/JNPF/uc 迁移 P0 修复
- /sign/api/oauth/v20/me 归一化盲区:补 /api/oauth/v20/me 路由别名 - scope 逗号+空白切分(authorize 与 has_openid 同口径,避免逗号串吞 id_token) - mobile 身份字段走 User.extra 全链(check_mobile/create/set_profile/claims/me), me 补 MaxKey 别名字段 id/userId/displayName/fullName - 单点注销:/logout、/sign/logout 别名 + redirect_uri 302 回跳 (client 白名单,未登记 400;302 同时清会话 cookie) - 管理员重置密码入口统一过 accounts::check_password - e2e 互通套新增 A2b/A2c/A2d/A2e/A8b 六条断言,六套回归 rc=0
This commit is contained in:
1 parent
71809a4090
commit
6409d42817
5 files changed
+148
-10
No files matched your search
@@ -177,3 +177,15 @@
|
||||
> 顺带的收益:iPass 与 SSO 原先各有一份 `oauth.rs`(差异 425 行)、`users.rs`(525 行)、
|
||||
> `models.rs`(234 行),内核化后只保留一份。
|
||||
> 架构论证(为什么不拆多 .so)见 `docs/plugin-architecture-analysis.md`。
|
||||
|
||||
## [x] v3:MaxKey/JNPF/uc 迁移 P0 补齐(2026-09-13 完成)
|
||||
|
||||
> 背景与逐项依据:`docs/maxkey-to-ipass-migration-gap.md`(§0.5 执行状态表)。
|
||||
|
||||
- [x] `/sign/api/oauth/v20/me` 路由别名(MaxKey 真实 userinfo 路径,归一化盲区 404)
|
||||
- [x] scope 逗号+空白切分(authorize 校验与 `has_openid` 同口径;逗号串原先直接 invalid_scope 且吞 id_token)
|
||||
- [x] `mobile` 身份字段(`User.extra` 通道,check_mobile 校验,create/set_profile/管理台/claims/me 全链)
|
||||
- [x] me 响应 MaxKey 别名字段:`id`/`userId`/`displayName`/`fullName`(uc 按 maxkey_user_id 建档依赖)
|
||||
- [x] 单点注销:`/logout`、`/sign/logout` 别名 + `redirect_uri` 302 回跳(client 白名单,未登记 400;302 同时清会话 cookie)
|
||||
- [x] 管理员重置密码入口统一过 `check_password`(原可绕过插件层 8 位策略)
|
||||
- [x] e2e:互通套新增 A2b/A2c/A2d/A2e/A8b 六条断言,六套 rc=0
|
||||
@@ -46,6 +46,7 @@ const HIDDEN_EXTRA_KEYS: &[&str] = &["totp_secret"];
|
||||
pub const EXTRA_EMAIL: &str = "email";
|
||||
pub const EXTRA_DEPARTMENT: &str = "department";
|
||||
pub const EXTRA_GROUPS: &str = "groups";
|
||||
pub const EXTRA_MOBILE: &str = "mobile";
|
||||
pub const EXTRA_FAILED_COUNT: &str = "failed_count";
|
||||
pub const EXTRA_LOCKED_UNTIL: &str = "locked_until";
|
||||
|
||||
@@ -56,6 +57,7 @@ pub const EXTRA_LOCKED_UNTIL: &str = "locked_until";
|
||||
pub trait UserExt {
|
||||
// ---- 读 ----
|
||||
fn email(&self) -> &str;
|
||||
fn mobile(&self) -> &str;
|
||||
fn department(&self) -> &str;
|
||||
/// 用户组(同时接受 `["a","b"]` 数组与 `"a,b"` CSV 两种存量写法)
|
||||
fn groups(&self) -> Vec<String>;
|
||||
@@ -74,6 +76,7 @@ pub trait UserExt {
|
||||
fn extra_str_list(&self, key: &str) -> Vec<String>;
|
||||
// ---- 写(在 `store::update_users` / `users::update_extra` 闭包内用)----
|
||||
fn set_email(&mut self, v: &str);
|
||||
fn set_mobile(&mut self, v: &str);
|
||||
fn set_department(&mut self, v: &str);
|
||||
fn set_groups(&mut self, v: Vec<String>);
|
||||
fn set_failed_count(&mut self, v: i64);
|
||||
@@ -84,6 +87,9 @@ impl UserExt for User {
|
||||
fn email(&self) -> &str {
|
||||
self.extra_str(EXTRA_EMAIL)
|
||||
}
|
||||
fn mobile(&self) -> &str {
|
||||
self.extra_str(EXTRA_MOBILE)
|
||||
}
|
||||
fn department(&self) -> &str {
|
||||
self.extra_str(EXTRA_DEPARTMENT)
|
||||
}
|
||||
@@ -144,6 +150,10 @@ impl UserExt for User {
|
||||
fn set_email(&mut self, v: &str) {
|
||||
self.extra.insert(EXTRA_EMAIL.to_owned(), Value::String(v.to_owned()));
|
||||
}
|
||||
fn set_mobile(&mut self, v: &str) {
|
||||
self.extra
|
||||
.insert(EXTRA_MOBILE.to_owned(), Value::String(v.to_owned()));
|
||||
}
|
||||
fn set_department(&mut self, v: &str) {
|
||||
self.extra
|
||||
.insert(EXTRA_DEPARTMENT.to_owned(), Value::String(v.to_owned()));
|
||||
@@ -214,6 +224,22 @@ pub fn check_email(raw: &str) -> Result<String, String> {
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
/// 手机号:宽松校验(国际号允许 + 前缀),不接受控制字符与空白——
|
||||
/// 它会进 OIDC claims 与接入方建档(uc_user.phone)。
|
||||
pub fn check_mobile(raw: &str) -> Result<String, String> {
|
||||
let v = util::trim(raw).to_owned();
|
||||
if v.is_empty() {
|
||||
return Ok(v);
|
||||
}
|
||||
if v.len() > 32 || v.chars().any(|c| c.is_control() || c.is_whitespace()) {
|
||||
return Err("手机号格式不正确".to_owned());
|
||||
}
|
||||
if !v.chars().all(|c| c.is_ascii_digit() || c == '+') {
|
||||
return Err("手机号只能包含数字与 + 前缀".to_owned());
|
||||
}
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
/// 部门名:禁止控制字符。
|
||||
pub fn check_department(raw: &str) -> Result<String, String> {
|
||||
let v = util::trim(raw).to_owned();
|
||||
@@ -259,6 +285,7 @@ pub fn create(
|
||||
password: &str,
|
||||
role: &str,
|
||||
email: &str,
|
||||
mobile: &str,
|
||||
department: &str,
|
||||
groups: &str,
|
||||
) -> Result<User, String> {
|
||||
@@ -273,6 +300,7 @@ pub fn create(
|
||||
let display_name = check_display_name(&display_name)?;
|
||||
check_password(password)?;
|
||||
let email = check_email(email)?;
|
||||
let mobile = check_mobile(mobile)?;
|
||||
let department = check_department(department)?;
|
||||
let groups = check_groups(groups)?;
|
||||
let role = if role == "admin" { "admin" } else { "user" }.to_owned();
|
||||
@@ -294,6 +322,7 @@ pub fn create(
|
||||
extra: BTreeMap::new(),
|
||||
};
|
||||
user.set_email(&email);
|
||||
user.set_mobile(&mobile);
|
||||
user.set_department(&department);
|
||||
user.set_groups(groups);
|
||||
|
||||
@@ -315,11 +344,13 @@ pub fn create(
|
||||
pub fn set_profile(
|
||||
username: &str,
|
||||
email: &str,
|
||||
mobile: &str,
|
||||
department: &str,
|
||||
groups_raw: &str,
|
||||
display_name: Option<&str>,
|
||||
) -> Result<User, String> {
|
||||
let email = check_email(email)?;
|
||||
let mobile = check_mobile(mobile)?;
|
||||
let department = check_department(department)?;
|
||||
let groups = check_groups(groups_raw)?;
|
||||
let display_name = match display_name {
|
||||
@@ -330,6 +361,7 @@ pub fn set_profile(
|
||||
store::update_users(move |users: &mut UserTable| {
|
||||
let user = users.get_mut(username).ok_or("账号不存在")?;
|
||||
user.set_email(&email);
|
||||
user.set_mobile(&mobile);
|
||||
user.set_department(&department);
|
||||
user.set_groups(groups);
|
||||
if let Some(d) = display_name {
|
||||
@@ -493,6 +525,7 @@ pub fn view(user: &User) -> Value {
|
||||
"role": user.role,
|
||||
"is_admin": user.is_admin(),
|
||||
"email": user.email(),
|
||||
"mobile": user.mobile(),
|
||||
"department": user.department(),
|
||||
"groups": user.groups(),
|
||||
"groups_csv": user.groups_csv(),
|
||||
@@ -510,7 +543,7 @@ pub fn view(user: &User) -> Value {
|
||||
continue;
|
||||
}
|
||||
// 身份字段已按强类型透出,不重复塞第二份
|
||||
if matches!(k.as_str(), EXTRA_EMAIL | EXTRA_DEPARTMENT | EXTRA_GROUPS | EXTRA_FAILED_COUNT | EXTRA_LOCKED_UNTIL) {
|
||||
if matches!(k.as_str(), EXTRA_EMAIL | EXTRA_MOBILE | EXTRA_DEPARTMENT | EXTRA_GROUPS | EXTRA_FAILED_COUNT | EXTRA_LOCKED_UNTIL) {
|
||||
continue;
|
||||
}
|
||||
obj.insert(k.clone(), val.clone());
|
||||
|
||||
@@ -130,7 +130,15 @@ fn route(method: &str, uri: &str) -> Option<(Guard, Handler)> {
|
||||
("POST", "/oauth/v20/token") => (Guard::Public, h_oauth_token_v20),
|
||||
("GET", "/oauth/v20/me") => (Guard::Public, h_oauth_me_v20),
|
||||
("POST", "/oauth/v20/me") => (Guard::Public, h_oauth_me_v20),
|
||||
// MaxKey 真实 userinfo 路径挂在 /sign/api 下(不是 /sign/authz):
|
||||
// `/sign/api/oauth/v20/me` 经归一化剥掉 `/sign` 后落到这里。
|
||||
// JNPF yml 的 userInfoUrl 与照抄 MaxKey 文档的客户端默认推导都是该路径。
|
||||
("GET", "/api/oauth/v20/me") => (Guard::Public, h_oauth_me_v20),
|
||||
("POST", "/api/oauth/v20/me") => (Guard::Public, h_oauth_me_v20),
|
||||
("GET", "/oauth/v20/logout") => (Guard::Public, h_oauth_logout),
|
||||
// 单点注销的裸路径:`/sign/logout`、`/maxkey/logout` 经归一化剥前缀后落到这里。
|
||||
("GET", "/logout") => (Guard::Public, h_oauth_logout),
|
||||
("POST", "/logout") => (Guard::Public, h_oauth_logout),
|
||||
("GET", "/oauth2.0/authorize") => (Guard::Public, h_oauth_authorize),
|
||||
("GET", "/oauth2.0/accessToken") => (Guard::Public, h_oauth_token_v20),
|
||||
("POST", "/oauth2.0/accessToken") => (Guard::Public, h_oauth_token_v20),
|
||||
@@ -636,6 +644,7 @@ fn h_admin_user_create(r: *mut ngx_http_request_t, actor: Actor) -> Status {
|
||||
p.get("password").map(String::as_str).unwrap_or(""),
|
||||
p.get("role").map(String::as_str).unwrap_or("user"),
|
||||
p.get("email").map(String::as_str).unwrap_or(""),
|
||||
p.get("mobile").map(String::as_str).unwrap_or(""),
|
||||
p.get("department").map(String::as_str).unwrap_or(""),
|
||||
p.get("groups").map(String::as_str).unwrap_or(""),
|
||||
) {
|
||||
@@ -677,6 +686,7 @@ fn h_admin_user_profile(r: *mut ngx_http_request_t, actor: Actor) -> Status {
|
||||
match accounts::set_profile(
|
||||
&username,
|
||||
p.get("email").map(String::as_str).unwrap_or(""),
|
||||
p.get("mobile").map(String::as_str).unwrap_or(""),
|
||||
p.get("department").map(String::as_str).unwrap_or(""),
|
||||
p.get("groups").map(String::as_str).unwrap_or(""),
|
||||
display_name,
|
||||
@@ -806,6 +816,13 @@ fn h_admin_user_password(r: *mut ngx_http_request_t, actor: Actor) -> Status {
|
||||
let username = p.get("username").map(|s| util::trim(s).to_owned()).unwrap_or_default();
|
||||
let password = p.get("password").map(String::as_str).unwrap_or("");
|
||||
|
||||
// 密码策略统一在插件层入口把关:内核 set_password 只管共性(最小 6 位),
|
||||
// 这里用本插件的收紧策略(8 位 + 无控制字符),管理员重置也不例外——
|
||||
// 否则「管理员图省事重置成 123」绕过策略,账户锁定防线形同虚设。
|
||||
if let Err(e) = accounts::check_password(password) {
|
||||
return http::fail(r, HTTPStatus::BAD_REQUEST, &e);
|
||||
}
|
||||
|
||||
match users::set_password(&username, password) {
|
||||
Ok(()) => {
|
||||
audit::log("admin.user.password", actor.admin_name(), &username, true, &http::remote_addr(r), &http::header(r, "user-agent").unwrap_or_default(), "");
|
||||
|
||||
@@ -411,6 +411,7 @@ fn mint_access_token(
|
||||
name: &str,
|
||||
groups: &[String],
|
||||
department: &str,
|
||||
mobile: &str,
|
||||
client_id: &str,
|
||||
scope: &str,
|
||||
now: i64,
|
||||
@@ -426,6 +427,8 @@ fn mint_access_token(
|
||||
"preferred_username": sub,
|
||||
"name": name,
|
||||
"email": email,
|
||||
// 手机号:接入方(uc_user.phone 等)建档依赖;空值也写键,保证 claim 形状稳定
|
||||
"mobile": mobile,
|
||||
"department": department,
|
||||
"groups": groups,
|
||||
"scope": scope,
|
||||
@@ -626,8 +629,10 @@ pub fn authorize(r: *mut ngx_http_request_t) -> Status {
|
||||
if response_type != "code" {
|
||||
return oauth_error(r, HTTPStatus::BAD_REQUEST, "unsupported_response_type", "仅支持 code");
|
||||
}
|
||||
// scope 必须全部在白名单内
|
||||
for s in scope.split_whitespace() {
|
||||
// scope 必须全部在白名单内。按逗号与空白一起切:MaxKey 文档示例与
|
||||
// ssw-admin/JNPF 客户端实际发的是 "openid,profile,email"(逗号分隔),
|
||||
// 只按空白切会把整串当一个 scope,精确匹配必挂 invalid_scope。
|
||||
for s in scope.split(|c: char| c == ',' || c.is_whitespace()).filter(|s| !s.is_empty()) {
|
||||
if !client.allows_scope(s) {
|
||||
return oauth_error(r, HTTPStatus::BAD_REQUEST, "invalid_scope", &format!("不允许的 scope: {s}"));
|
||||
}
|
||||
@@ -771,7 +776,7 @@ fn token_impl(r: *mut ngx_http_request_t, bare: bool) -> Status {
|
||||
}
|
||||
let scope = p.get("scope").cloned().unwrap_or_else(|| "openid".to_owned());
|
||||
let Some(access) = mint_access_token(
|
||||
&client.client_id, "", &client.name, &[], "", &client.client_id, &scope, now,
|
||||
&client.client_id, "", &client.name, &[], "", "", &client.client_id, &scope, now,
|
||||
) else {
|
||||
return oauth_error(r, HTTPStatus::INTERNAL_SERVER_ERROR, "server_error", "令牌签发不可用");
|
||||
};
|
||||
@@ -842,17 +847,18 @@ fn issue_tokens(
|
||||
bare: bool,
|
||||
) -> Status {
|
||||
let user = users::get(sub);
|
||||
let (email, name, groups, department) = match &user {
|
||||
Some(u) => (u.email().to_owned(), if u.display_name.is_empty() { u.username.clone() } else { u.display_name.clone() }, u.groups(), u.department().to_owned()),
|
||||
None => (String::new(), sub.to_owned(), vec![], String::new()),
|
||||
let (email, name, groups, department, mobile) = match &user {
|
||||
Some(u) => (u.email().to_owned(), u.display_or_username(), u.groups(), u.department().to_owned(), u.mobile().to_owned()),
|
||||
None => (String::new(), sub.to_owned(), vec![], String::new(), String::new()),
|
||||
};
|
||||
let (Some(access), Some(refresh)) = (
|
||||
mint_access_token(sub, &email, &name, &groups, &department, &client.client_id, scope, now),
|
||||
mint_access_token(sub, &email, &name, &groups, &department, &mobile, &client.client_id, scope, now),
|
||||
mint_refresh_token(sub, &client.client_id, now),
|
||||
) else {
|
||||
return oauth_error(r, HTTPStatus::INTERNAL_SERVER_ERROR, "server_error", "令牌签发不可用");
|
||||
};
|
||||
let has_openid = scope.split_whitespace().any(|s| s == "openid");
|
||||
// 与 authorize 的切分口径保持一致(逗号分隔串里 "openid" 不在空白边界上)
|
||||
let has_openid = scope.split(|c: char| c == ',' || c.is_whitespace()).any(|s| s == "openid");
|
||||
let mut body = json!({
|
||||
"access_token": access,
|
||||
"token_type": "Bearer",
|
||||
@@ -909,14 +915,24 @@ pub fn userinfo_v20(r: *mut ngx_http_request_t) -> Status {
|
||||
None => return oauth_error(r, HTTPStatus::UNAUTHORIZED, "invalid_token", "令牌无效或过期"),
|
||||
};
|
||||
let g = |k: &str| claims.get(k).cloned().unwrap_or(Value::Null);
|
||||
// 手机号:access_token claims 带 mobile(签发时从用户档案取),空则透出 null。
|
||||
let mobile = g("mobile");
|
||||
let out = json!({
|
||||
// MaxKey 语义:username / userid 是**登录账号**,realname 才是真实姓名。
|
||||
// 显示名塞进 username 会让第三方系统按账号查找用户时匹配不上。
|
||||
"username": g("sub"),
|
||||
"userid": g("sub"),
|
||||
// `id`/`userId`:MaxKey /me 返回用户主键,uc 等接入方按它做全局身份
|
||||
// 映射(maxkey_user_id)。本网关以 username 为稳定主键(不可改),
|
||||
// 与 `sub`/`userid` 同值。
|
||||
"id": g("sub"),
|
||||
"userId": g("sub"),
|
||||
// `displayName`/`fullName`:MaxKey 客户端的展示名取值顺序里常见的键。
|
||||
"displayName": g("name"),
|
||||
"fullName": g("name"),
|
||||
"realname": g("name"),
|
||||
"email": g("email"),
|
||||
"mobile": Value::Null,
|
||||
"mobile": mobile,
|
||||
// ---- 标准 OIDC 声明 ----
|
||||
"sub": g("sub"),
|
||||
"preferred_username": g("preferred_username"),
|
||||
@@ -1149,12 +1165,46 @@ pub fn login_post(r: *mut ngx_http_request_t) -> Status {
|
||||
|
||||
/// POST /oauth/logout —— 销毁 SSO 会话。
|
||||
pub fn logout(r: *mut ngx_http_request_t) -> Status {
|
||||
// 清共享内存里的 SSO 会话(顺带取用户名写审计)。
|
||||
let now = util::now();
|
||||
let mut who = String::new();
|
||||
if let Some(tok) = parse_cookie(http::header(r, "cookie").as_deref(), OAUTH_SESSION_COOKIE) {
|
||||
if let Some(payload) = crate::oauth_state::get_oauth_session(&tok, now) {
|
||||
who = payload.split('\n').next().unwrap_or("").to_owned();
|
||||
}
|
||||
crate::oauth_state::remove_oauth_session(&tok);
|
||||
}
|
||||
let cleared = format!(
|
||||
"{OAUTH_SESSION_COOKIE}=deleted; Path=/; HttpOnly; SameSite=Lax; Max-Age=0"
|
||||
);
|
||||
let ip = http::remote_addr(r);
|
||||
let ua = http::header(r, "user-agent").unwrap_or_default();
|
||||
|
||||
// 单点注销回跳:消费方(JNPF/uc)登出时把浏览器 302 到这里,
|
||||
// 带上 `redirect_uri` 让 IdP 清完会话再跳回业务侧。
|
||||
// 开放重定向防线:必须是 http(s) 绝对地址,且命中任一已登记 client
|
||||
// 的回调白名单——登出页不该是免费跳板。
|
||||
let p = http::params(r);
|
||||
let back = p.get("redirect_uri").or_else(|| p.get("redirect")).map(String::as_str).unwrap_or("");
|
||||
if !back.is_empty() {
|
||||
let allowed = (back.starts_with("http://") || back.starts_with("https://"))
|
||||
&& oauth_clients::all().iter().any(|c| c.allows_redirect(back));
|
||||
if allowed {
|
||||
audit::log("oauth.logout", &who, back, true, &ip, &ua, "slo");
|
||||
// 302 的同时必须把会话 cookie 清掉:Location 跳转不吞 Set-Cookie,
|
||||
// 漏了它浏览器侧会话残留,下次点 SSO 登录会静默重登录。
|
||||
return http::send_with(
|
||||
r,
|
||||
HTTPStatus(302),
|
||||
"{\"code\":302,\"msg\":\"redirect\"}",
|
||||
&[("Location", back), ("Set-Cookie", cleared.as_str())],
|
||||
);
|
||||
}
|
||||
audit::log("oauth.logout", &who, back, false, &ip, &ua, "redirect 拒绝");
|
||||
return http::fail(r, HTTPStatus::BAD_REQUEST, "redirect_uri 未登记,拒绝回跳");
|
||||
}
|
||||
|
||||
audit::log("oauth.logout", &who, "", true, &ip, &ua, "");
|
||||
http::ok_with(r, json!({}), "已退出登录", &[("Set-Cookie", &cleared)])
|
||||
}
|
||||
|
||||
@@ -1205,6 +1255,7 @@ pub fn iap_identity(r: *mut ngx_http_request_t) -> Option<(String, String, Strin
|
||||
&name,
|
||||
&groups.split(',').filter(|s| !s.is_empty()).map(|s| s.to_owned()).collect::<Vec<_>>(),
|
||||
&department,
|
||||
"",
|
||||
IAP_TOKEN_AUDIENCE,
|
||||
IAP_TOKEN_SCOPE,
|
||||
now,
|
||||
|
||||
@@ -144,6 +144,26 @@ for P in "/maxkey/oauth/v20/authorize" "/sign/authz/oauth/v20/authorize" "/oauth
|
||||
if [ "$CODE" = "302" ]; then ok "GET $P 命中(context-path 归一化)"; else bad "GET $P 期望 302,实得 $CODE"; fi
|
||||
done
|
||||
|
||||
# A2b. `/sign/api/oauth/v20/me`:MaxKey 真实 userinfo 路径挂在 /sign/api 下
|
||||
# (不是 /sign/authz)——曾是 context-path 归一化盲区,404 回归线
|
||||
CODE="$(curl -s -o /dev/null -w '%{http_code}' "$IDP/sign/api/oauth/v20/me")"
|
||||
if [ "$CODE" != "404" ] && [ "$CODE" != "000" ]; then ok "GET /sign/api/oauth/v20/me 命中(${CODE},非 404)"; else bad "/sign/api/oauth/v20/me 404,归一化盲区回归($CODE)"; fi
|
||||
|
||||
# A2c. 逗号分隔 scope(MaxKey 文档示例写法 "openid,profile,email"):
|
||||
# 校验应通过(未登录 → 302 跳登录),而不是 invalid_scope 400
|
||||
CODE="$(curl -s -o /dev/null -w '%{http_code}' "$IDP/sign/authz/oauth/v20/authorize?client_id=demo-system&response_type=code&redirect_uri=$REDIRECT&scope=openid,profile,email")"
|
||||
if [ "$CODE" = "302" ]; then ok "authorize 逗号 scope 通过(302 跳登录)"; else bad "逗号 scope 被拒(期望 302,实得 $CODE)"; fi
|
||||
|
||||
# A2d. 单点注销裸路径:/sign/logout 经归一化命中
|
||||
CODE="$(curl -s -o /dev/null -w '%{http_code}' "$IDP/sign/logout")"
|
||||
if [ "$CODE" != "404" ] && [ "$CODE" != "000" ]; then ok "GET /sign/logout 命中(${CODE})"; else bad "/sign/logout 未命中($CODE)"; fi
|
||||
|
||||
# A2e. 注销回跳:已登记 redirect_uri → 302;未登记 → 400 拒绝(开放重定向防线)
|
||||
CODE="$(curl -s -o /dev/null -w '%{http_code}' "$IDP/sign/logout?redirect_uri=$REDIRECT")"
|
||||
if [ "$CODE" = "302" ]; then ok "logout 带已登记 redirect_uri → 302 回跳"; else bad "logout 回跳期望 302,实得 $CODE"; fi
|
||||
CODE="$(curl -s -o /dev/null -w '%{http_code}' "$IDP/sign/logout?redirect_uri=http://evil.example.com/cb")"
|
||||
if [ "$CODE" = "400" ]; then ok "logout 未登记 redirect_uri 被拒(400)"; else bad "开放重定向防线失效(期望 400,实得 $CODE)"; fi
|
||||
|
||||
# A3. token 端点别名存在(缺参数应 4xx,而不是 404)
|
||||
CODE="$(curl -s -o /dev/null -w '%{http_code}' -X POST "$IDP/sign/authz/oauth/v20/token" -d 'grant_type=authorization_code')"
|
||||
if [ "$CODE" != "404" ] && [ "$CODE" != "000" ]; then ok "POST /sign/authz/oauth/v20/token 命中(${CODE},非 404)"; else bad "token 别名未命中(${CODE})"; fi
|
||||
@@ -197,6 +217,11 @@ fi
|
||||
ME2="$(curl -s "$IDP/oauth2.0/profile?access_token=$AT")"
|
||||
if [ "$(tj "$ME2" username)" = "alice" ]; then ok "GET /oauth2.0/profile 别名命中"; else bad "/oauth2.0/profile 别名异常:$ME2"; fi
|
||||
|
||||
# A8b. /me 的 MaxKey 别名字段:id/userId(全局身份映射键)+ displayName
|
||||
U_ID2="$(tj "$ME_JSON" id)"
|
||||
U_DN="$(tj "$ME_JSON" displayName)"
|
||||
if [ "$U_ID2" = "alice" ] && [ -n "$U_DN" ]; then ok "/me 别名字段 id/userId/displayName 正常"; else bad "/me 别名字段异常(id=$U_ID2, displayName=$U_DN)"; fi
|
||||
|
||||
# A9. 标准端点不受影响(回归):Bearer 头 + userinfo 信封
|
||||
STD="$(curl -s "$IDP/oauth/userinfo" -H "Authorization: Bearer $AT")"
|
||||
if [ "$(printf '%s' "$STD" | python3 -c "
|
||||
|
||||
Reference in new issue
Block a user