-
Notifications
You must be signed in to change notification settings - Fork 54
fix: enforce ensureCloudToken invite policy #1445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ 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".
| return ctx.db | ||
| .select() | ||
| .from(sqlAppIdBinding) | ||
| .innerJoin(sqlLedgers, and(eq(sqlLedgers.ledgerId, sqlAppIdBinding.ledgerId), ...filters)) | ||
| .where(and(eq(sqlAppIdBinding.appId, req.appId), eq(sqlAppIdBinding.env, req.env ?? "prod"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid filtering existing appId binding by requested tenant
The new getExistingAppIdBinding reuses the caller-provided filters (tenant/ledger) when checking whether an appId is already registered. If an uninvited user supplies a different tenant (or ledger) than the one that owns the appId, this lookup returns null and ensureCloudToken proceeds to create a second binding as long as maxAppIdBindings is not exceeded. That bypasses the intended “appId already registered, ask the owner for an invite” guard. The existing-binding check should ignore tenant/ledger filters and search by appId/env only so uninvited users cannot opt out of the policy by passing alternate scopes.
Useful? React with 👍 / 👎.
WalkthroughThis pull request updates the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (3)📚 Learning: 2025-09-10T09:53:26.979ZApplied to files:
📚 Learning: 2025-09-09T20:13:36.836ZApplied to files:
📚 Learning: 2025-09-09T19:56:31.545ZApplied to files:
🧬 Code graph analysis (1)dashboard/backend/public/ensure-cloud-token.ts (6)
🪛 GitHub Actions: @fireproof/dashboarddashboard/backend/public/ensure-cloud-token.ts[error] 1-1: Prettier formatting check failed. File has formatting issues (public/ensure-cloud-token.ts). Run 'prettier --write' to fix the code style. 🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Testing
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.