feat: add policy-driven grant routing#88
Conversation
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat: add policy-driven grant routing This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 738dc38470
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const entry of entries) { | ||
| const tenant = entry.policy.tenantId ?? tenantId; | ||
| if (await selectGrant(providerId, entry.policyId, tenant, providerId, env)) return entry; | ||
| if ((await resolveGrantSelection(providerId, entry.policyId, tenant, providerId, env, new Set(), entry.policy.grantRouting, null, false)).selected) return entry; |
There was a problem hiding this comment.
Honor fail-closed policies during Access selection
When a Cloudflare Access identity has multiple matching policies, this checks only .selected and skips a higher-priority policy whose routing intentionally returns no grant while hasConfiguredGrant is true, e.g. eligibleGrants: { openai: [] } or staleState: "deny" with no fresh state. The request can then run under a lower-priority policy with an available grant, bypassing the new fail-closed/allowlist contract for browser Access flows; proxy-key flows still enforce it because they use the credential's single policy directly.
Useful? React with 👍 / 👎.
Summary
Validation
pnpm check(62 worker, 26 admin, 43 script tests)pnpm buildpnpm worker:e2eCloses #59