Skip to content

Commit fb79dd7

Browse files
authored
fix: Invalidate oauth credentials when oauth provider says so (anomalyco#14007)
Co-authored-by: Eduardo Gomes <egomes@cloudflare.com>
1 parent 4025b65 commit fb79dd7

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

packages/opencode/src/mcp/oauth-provider.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,28 @@ export class McpOAuthProvider implements OAuthClientProvider {
149149
}
150150
return entry.oauthState
151151
}
152+
153+
async invalidateCredentials(type: "all" | "client" | "tokens"): Promise<void> {
154+
log.info("invalidating credentials", { mcpName: this.mcpName, type })
155+
const entry = await McpAuth.get(this.mcpName)
156+
if (!entry) {
157+
return
158+
}
159+
160+
switch (type) {
161+
case "all":
162+
await McpAuth.remove(this.mcpName)
163+
break
164+
case "client":
165+
delete entry.clientInfo
166+
await McpAuth.set(this.mcpName, entry)
167+
break
168+
case "tokens":
169+
delete entry.tokens
170+
await McpAuth.set(this.mcpName, entry)
171+
break
172+
}
173+
}
152174
}
153175

154176
export { OAUTH_CALLBACK_PORT, OAUTH_CALLBACK_PATH }

0 commit comments

Comments
 (0)