Skip to content

Commit 329dce8

Browse files
antfuclaude
andcommitted
fix: config-based auth tokens should not persist to trusted storage
clientAuthTokens from config were being stored in trusted storage on auto-approve, which meant revoking them from self-inspect had no effect since the next auth request would re-match the config and re-store. Now config-based tokens only grant session-level trust (in-memory meta) without persisting to storage. Only terminal-approved and temp-token approved auth tokens are persisted. Also use delete instead of = undefined for immer draft cleanup on revoke. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b9cc9bc commit 329dce8

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

packages/core/src/node/auth-revoke.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function revokeAuthToken(
1414
): Promise<void> {
1515
// Remove from persistent storage
1616
storage.mutate((state) => {
17-
state.trusted[token] = undefined
17+
delete state.trusted[token]
1818
})
1919

2020
const rpcHost = context.rpc as unknown as RpcFunctionsHost

packages/core/src/node/rpc/anonymous/auth.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,18 @@ export const anonymousAuth = defineRpcFunction({
4040
}
4141
}
4242

43-
// Auto-approve if authToken matches a configured auth token or the temp auth ID
43+
// Auto-approve if authToken matches a configured auth token (session-only, not persisted)
4444
const tokens = (context.viteConfig.devtools?.config as any)?.clientAuthTokens as string[] ?? []
45-
if (tokens.includes(query.authToken) || query.authToken === getTempAuthToken()) {
45+
if (tokens.includes(query.authToken)) {
46+
session.meta.clientAuthToken = query.authToken
47+
session.meta.isTrusted = true
48+
return {
49+
isTrusted: true,
50+
}
51+
}
52+
53+
// Auto-approve if authToken matches the server-generated temp auth token
54+
if (query.authToken === getTempAuthToken()) {
4655
storage.mutate((state) => {
4756
state.trusted[query.authToken] = {
4857
authToken: query.authToken,

0 commit comments

Comments
 (0)