Skip to content

Commit 3d30ef9

Browse files
wesmclaude
andcommitted
Validate token client when inheriting stored oauth_app binding
Previously, re-running add-account on a named-app account without --oauth-app skipped client validation because the binding was inherited, not explicit. A stale token from a different client would be silently accepted and fail on next refresh. Now checks whenever resolvedApp is non-empty, regardless of source. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 306533d commit 3d30ef9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cmd/msgvault/cmd/addaccount.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ Examples:
135135
}
136136

137137
// If a valid token exists, check if we can reuse it.
138-
// When --oauth-app is explicitly set (any value including empty),
139-
// verify the token was minted by the resolved app's client.
140-
// A mismatched token would fail on next refresh.
141-
needsClientCheck := bindingChanged || oauthAppExplicit
138+
// Validate the token's client identity when any named app is
139+
// involved — whether from an explicit flag, a binding change,
140+
// or inherited from the DB. A mismatched token would fail on
141+
// next refresh.
142+
needsClientCheck := bindingChanged || oauthAppExplicit ||
143+
resolvedApp != ""
142144
tokenReusable := !forceReauth && oauthMgr.HasToken(email) &&
143145
(!needsClientCheck || oauthMgr.TokenMatchesClient(email))
144146
if tokenReusable {

0 commit comments

Comments
 (0)