Skip to content

Feat/tap 11883 token url - #633

Merged
weiliang110100 merged 4 commits into
developfrom
feat/TAP-11883-token-url
Oct 10, 2026
Merged

weiliang110100 merged 4 commits into
developfrom
feat/TAP-11883-token-url

Conversation

@weiliang110100

Copy link
Copy Markdown
Contributor

No description provided.

Stop appending access_token to REST, download, WS, and SSO URLs.
Use Authorization Bearer, blob downloads, PDK icon object URLs,
SAML login_code exchange, and keepalive fetch on data-preview unload.
Match restored TM ACS redirect; still strip the token from the
address bar after copying it into the session cookie.
@weiliang110100
weiliang110100 marked this pull request as draft September 16, 2026 09:51
@weiliang110100
weiliang110100 marked this pull request as ready for review September 29, 2026 04:02

@feynmx feynmx left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移至行内评论。

Comment thread apps/daas/src/main.ts Outdated
const [hashPath, hashQuery] = location.hash.split('?')
if (hashQuery) {
const params = new URLSearchParams(hashQuery)
params.delete('token')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] SAML 回调实际携带 access_token(SsoCallback.vue 读取该参数),但这里仅删除 token,且清理分支要求 getUrlSearch('token') 命中,因此回调不会执行清理。回调随后异步初始化;若恢复 lastLocationHref,还会用 location.href 新增历史项,留下带凭证的回调 URL。请在读取 access_token 后、任何 await 之前立即清理 URL。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复(2f688ddfa)。

  • 新增公共函数 removeUrlParams(...names)(apps/daas/src/utils/util.ts):用 history.replaceState 同时清理 query 和 hash 中的指定参数,不新增历史记录;同时同步 vue-router 的 history.state.current,避免 state 里残留带 token 的路由。
  • SsoCallback.vue 在读取 access_token 后、任何 await 之前立即调用 removeUrlParams('access_token'),后续 lastLocationHref / location.href 跳转都拿不到带凭证的 URL。
  • main.ts 原有的 ?token= 清理也改为复用该函数。

}
}
if (config.url) {
config.url = stripUrlAccessToken(config.url)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] 这里只清理 Axios 请求。SAML 登出通过 window.location.href = getSamlLogoutUrl(accessToken) 导航,packages/api/src/core/sso.ts:38 仍会生成 /logout?access_token=...,所以该凭证绕过此拦截器并进入请求 URL。请一并调整登出调用和服务端契约,确保 URL 不再携带 token。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复(2f688ddfa),并同步调整了服务端契约:tapdata/tapdata#3516。

  • 前端:getSamlLogoutUrl(token) 改为 startSamlLogout(token),以 POST /api/sso/saml/logout + Authorization: Bearer 发起登出,后端返回 redirectUrl(IdP SLO 地址或登出后页面),signOut() 再跳转;请求失败时回到 #/login。登出 URL 不再携带 token。
  • 后端(#3516):新增 POST /logout,通过 AccessTokenResolver 从请求头解析 token;GET /logout 保留兼容旧前端并标记 deprecated,url-token-mode=REJECT 时忽略 URL token。

注意发布顺序:本 PR 依赖 #3516,需在后端合并部署后(或同时)再合并,否则 SAML 登出只会回到登录页而不会终止服务端会话 / 触发 IdP SLO。

- Strip access_token from the SSO callback URL right after reading it,
  before any await, so it never stays in the address bar, history or
  lastLocationHref; share the cleanup with the ?token= entry path.
- Start SAML logout via POST /api/sso/saml/logout with a Bearer header
  and navigate to the returned redirectUrl instead of putting the token
  in the logout URL. Requires the matching TM endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants