fix(rbac): restore channel API key permissions#2349
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
More reviews will be available in 23 minutes and 37 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (42)
Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
878bd7e to
5f10e30
Compare
5f10e30 to
a37b9f9
Compare
a37b9f9 to
7939157
Compare
7939157 to
4ae61b2
Compare
4ae61b2 to
d1cbfe6
Compare
9f4e13d to
c96d4e4
Compare
c96d4e4 to
8c03ee7
Compare
8c03ee7 to
5788b5c
Compare
5788b5c to
703d485
Compare
|
42Clownfish
left a comment
There was a problem hiding this comment.
Reviewed the channel RBAC/API-key compatibility path. No blocker from my pass.
What I checked:
post.tsnow separates create vs update: new channels requireapp.create_channel, existing channels requirechannel.update_settings, and version changes requirechannel.promote_bundleafter resolving the target version.- The migration mirrors that split in RLS for insert/update/delete, so the old CLI compatibility helpers only get callers to the endpoint/RLS gate; they do not become the final authorization decision.
- The regression coverage hits the important security cases: app developer channel creation, promote denial on direct channel version changes, hashed API-key scope, and forged app/channel binding rejection.
- Current checks are green, including backend lint/typecheck, SQL/RLS tests, CLI tests, CodeQL, Sonar, and Socket.
One non-blocking edge to keep an eye on: post.ts uses the caller's API-key client to discover existingChannel. If a channel exists but is not visible to that key, the code can classify the request as a create attempt and then rely on the upsert/RLS conflict to reject it. That still looks protected, but it may produce a noisier database error instead of the cleaner cannot_access_app response. If that matters for CLI UX, a service-role existence lookup followed by the same explicit permission checks would make the error path deterministic.



Summary (AI generated)
app.create_channeltoapp_developer.Motivation (AI generated)
A migrated API key could be reported as
writeby the legacy CLI permission helper even when it had channel/admin RBAC permissions. That made channel create/delete/self-set flows fail before the request reached the real RBAC/RLS checks.Business Impact (AI generated)
This restores customer channel management for migrated API keys without making write keys destructive: developer/write keys can create and update allowed channel settings, while channel deletion still requires
channel.delete. It also keeps older CLI compatibility through the existing RPC shape.Test Plan (AI generated)
bun run supabase:db:resetchannelsRLS policy per operation andapp_developerhasapp.create_channelbun run cli:lintbun run lint:backendbun run cli:typecheckbun run typecheck:backendbun run typecheck:frontendbun run lintbun run cli:buildbun run supabase:with-env -- bunx vitest run tests/channel-post.unit.test.ts tests/rbac-permissions.test.ts tests/hashed-apikey-rls.test.tsbun run supabase:with-env -- bunx vitest run tests/cli-channel.test.ts tests/cli-hashed-apikey.test.ts tests/channel.test.tsGenerated with AI