dsh-webui-oauth 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/index.js +9 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
本文件记录每个版本的**用户可见**变更。破坏性变更与升级动作单独标注。
|
|
4
4
|
|
|
5
|
+
## 0.6.5
|
|
6
|
+
|
|
7
|
+
补全 0.6.4 遗漏的路径:**SSO 登录成功后同样停在 JSON 页面上**。
|
|
8
|
+
|
|
9
|
+
### 修复:SSO 登录成功也改为 302 跳转
|
|
10
|
+
|
|
11
|
+
- **现象**:用 SSO 登录成功后,浏览器停在
|
|
12
|
+
`{"ok":true,"redirect":"http://…/?token=…"}` 上,不会自动进入应用。
|
|
13
|
+
(0.6.4 只改了绑定路径与失败路径,登录成功这条漏了。)
|
|
14
|
+
- **原因**:同一类问题——回调端点把跳转目标放在 JSON 的 `redirect` 字段里,
|
|
15
|
+
指望前端去跳。但 OIDC 回调是浏览器主导的顶层导航,此时页面上并没有插件的 JS
|
|
16
|
+
在运行(用户是从登录页点 SSO 被 302 到 IdP、再 302 回来的),没人会去读那个字段。
|
|
17
|
+
- **修复**:直接 `302` 到目标地址,并一次带两条 `Set-Cookie`(会话 + 清除一次性
|
|
18
|
+
state Cookie)。
|
|
19
|
+
|
|
20
|
+
### 说明:登录页表单仍返回 JSON(这是对的)
|
|
21
|
+
|
|
22
|
+
密码登录与首次初始化是登录页用 `fetch` 发起的,页面上有 JS 在跑并由它负责跳转,
|
|
23
|
+
因此这两处继续返回 `{"ok":true,"redirect":…}` 是正确设计,不在本次修改范围内。
|
|
24
|
+
|
|
25
|
+
### 测试
|
|
26
|
+
|
|
27
|
+
- `test/oidc-integration.test.mjs` 与 `test/oidc-bind.test.mjs` 中"回调成功"的断言
|
|
28
|
+
改为校验 302 + `Location` 带 launch token,而非 JSON 字段。
|
|
29
|
+
- 全量 343 项断言通过。
|
|
30
|
+
|
|
5
31
|
## 0.6.4
|
|
6
32
|
|
|
7
33
|
修复 OIDC 回调结束后浏览器**停在 JSON 页面上**、需要手动回退的问题。
|
package/index.js
CHANGED
|
@@ -2821,12 +2821,17 @@ export async function apply(ctx) {
|
|
|
2821
2821
|
// 本地用户名,拿它当身份会张冠李戴);审计里才用 sanitizeSub 过滤后的短标识。
|
|
2822
2822
|
const s = createSession(rawSub, ttlOf(creds))
|
|
2823
2823
|
await auditLog(ctx, 'oidc_login_success', { username: auditName, ip: meta.ip, ua: meta.ua })
|
|
2824
|
-
//
|
|
2825
|
-
//
|
|
2826
|
-
//
|
|
2827
|
-
|
|
2824
|
+
// 授权往返结束:直接 302 回应用,并同时下发会话 Cookie、清除一次性 state Cookie。
|
|
2825
|
+
//
|
|
2826
|
+
// 不能返回 {"ok":true,"redirect":...} 让前端去跳:OIDC 回调是浏览器主导的
|
|
2827
|
+
// 顶层导航,此时页面上并没有我们的 JS 在运行(用户是从登录页点了 SSO 按钮
|
|
2828
|
+
// 被 302 到 IdP 再 302 回来的),渲染 JSON 就停在死页面上了。
|
|
2829
|
+
// Set-Cookie 必须一次带两条(会话 + 清除 state),缺任一条都会出问题。
|
|
2830
|
+
res.writeHead(302, {
|
|
2831
|
+
location: postLoginRedirect(ctx, req),
|
|
2828
2832
|
'Set-Cookie': [sessionCookie(s.token, s.maxAge), clearStateCookie['Set-Cookie']],
|
|
2829
2833
|
})
|
|
2834
|
+
res.end()
|
|
2830
2835
|
} catch (e) {
|
|
2831
2836
|
// 这里可能带上用户可控内容(如 code 解码、payload 结构异常),
|
|
2832
2837
|
// 若原样回显会变成反射型注入的落点,因此固定文案、细节只进服务端日志。
|