mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
Merge pull request #322 from nwparker/cloud/w6-revoke-all-sandboxes
fix(cloud): a provider 401 refreshes all of the person's running sandboxes
This commit is contained in:
@@ -379,9 +379,10 @@ function egressRoutes(env: Env, deps: Deps): (row: SandboxRow, host: string) =>
|
||||
const handled = provider.onUnauthorized
|
||||
? keyring.then((ring) => provider.onUnauthorized!({ db: env.SANDBOX_DB, keyring: ring, userId: row.user_id, now, waitUntil }))
|
||||
: markAgentCredentialRevoked(env.SANDBOX_DB, row.user_id, agent, now)
|
||||
const work = handled.then(() => {
|
||||
// Every running sandbox of this person drops the dead placeholder, not only this one.
|
||||
const work = handled.then(async () => {
|
||||
forgetAccountCredential(row.user_id, agent)
|
||||
scheduleEnvRefresh(env, deps, row)
|
||||
await refreshOwnersSandboxes(env, deps, row.user_id)
|
||||
})
|
||||
if (deps.waitUntil) {
|
||||
deps.waitUntil(work.catch(() => undefined))
|
||||
|
||||
@@ -181,11 +181,19 @@ describe('egress-time Source (D10) and shared workspaces (D13)', () => {
|
||||
await h.call('PUT', '/v1/agent-credentials/claude', { bearer: mia, body: { token: SETUP_TOKEN } })
|
||||
const created = await h.call('POST', '/v1/sandboxes', { body: { workspaceId: 'ws-1', machineSize: 'standard' }, bearer: mia })
|
||||
const id: string = created.body.sandbox.id
|
||||
const other = await h.call('POST', '/v1/sandboxes', { body: { workspaceId: 'ws-2', machineSize: 'standard' }, bearer: mia })
|
||||
const otherSession: string = other.body.sandbox.session.id
|
||||
reply.status = 401
|
||||
expect((await proxied(id, 'api.anthropic.com', { authorization: `Bearer orca-ph-claude-account-${id}` })).status).toBe(401)
|
||||
expect((await h.call('GET', '/v1/agent-credentials', { bearer: mia })).body.claude.state).toBe('revoked')
|
||||
// Already off the account: no placeholder in new shells, and the proxy refuses with a clear reason.
|
||||
await vi.waitFor(() => expect(lastEnv(ENV_COMMAND).CLAUDE_CODE_OAUTH_TOKEN).toBeUndefined())
|
||||
// The person's other running workspace drops the dead placeholder too.
|
||||
await vi.waitFor(() => {
|
||||
const refreshed = h.vercel.commands.filter((c) => c.command === ENV_COMMAND && c.sessionId === otherSession)
|
||||
expect(refreshed.length).toBeGreaterThan(0)
|
||||
expect(decode(refreshed.at(-1)!.env.ORCA_SECRET_ENV).CLAUDE_CODE_OAUTH_TOKEN).toBeUndefined()
|
||||
})
|
||||
expect((await proxied(id, 'api.anthropic.com', { authorization: `Bearer orca-ph-claude-account-${id}` })).status).toBe(403)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user