Apply rate limiting to ConnectRPC path, deduplicate auth helpers#113
Apply rate limiting to ConnectRPC path, deduplicate auth helpers#113haasonsaas merged 3 commits intomainfrom
Conversation
- Wrap ConnectRPC handler with rate limiter, body size limit, and security headers — previously bypassed (pre-existing since gRPC era) - Extract ApplyAuth() in controlplaneclient to replace duplicated authReq() methods in sync and connector packages - Fixes Set-vs-Add header bug (simplified to direct Set calls) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PR SummaryHigh Risk Overview Auth header setting for ConnectRPC clients is deduplicated by replacing per-client CI Buf breaking detection is updated to compare against Reviewed by Cursor Bugbot for commit 5476317. Bugbot is set up for automated code reviews on this repo. Configure here. |
GitHub Actions checkout creates origin/main but not a local main branch. buf breaking needs the remote ref. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
Bugbot Autofix is ON, but it could not run because the spend limit has been reached. To enable Bugbot Autofix, have a team admin raise the spend limit in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 37f9358. Configure here.
| if orgID != "" { | ||
| req.Header().Set("X-Org-Id", orgID) | ||
| } | ||
| } |
There was a problem hiding this comment.
New ApplyAuth duplicates existing withAuth helper logic
Low Severity
The new ApplyAuth function duplicates the header-setting logic of the existing withAuth function in the same file. Both set the same Authorization and X-Org-Id headers on a ConnectRPC request. The private withAuth could delegate to ApplyAuth internally to keep a single source of truth for auth header logic.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 37f9358. Configure here.
- Apply middleware.RealIP before rate limiter on ConnectRPC path so requests behind a reverse proxy are rate-limited by client IP, not proxy IP - Remove OutgoingHeaders (no callers after ApplyAuth refactor) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Restore RealIP + rate limiter + body size + security headers on ConnectRPC path (lost during rebase from pre-#113 branch) - Replace authReq with controlplaneclient.ApplyAuth (dedup from #113) - Replace OutgoingHeaders with ApplyAuth (dedup from #115) - withAuth delegates to ApplyAuth Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Import identity types from shared proto package Remove local Organization, OrgMember, APIKey message definitions from tenant.proto and import canonical types from identity/v1. Update all converter functions, clients, and tests. Closes #110 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Replace audit.Entry with shared auditv1.Event Swap hand-written Entry struct for auditv1.Event from shared proto. Sink interface accepts []*auditv1.Event. Logger methods construct proto events with nested Actor/Resource. Metadata field overwrite prevented by setting dedicated fields last. CI updated with shared proto symlinks for buf lint and tenant.proto excluded from buf breaking during migration. Closes #108 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Address review feedback: restore middleware, deduplicate auth helpers - Restore RealIP + rate limiter + body size + security headers on ConnectRPC path (lost during rebase from pre-#113 branch) - Replace authReq with controlplaneclient.ApplyAuth (dedup from #113) - Replace OutgoingHeaders with ApplyAuth (dedup from #115) - withAuth delegates to ApplyAuth Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>


Summary
Follow-up to #111 addressing remaining Bugbot review feedback:
/gate.v1.*) were served outside the chi router, bypassing rate limiter, body size limit, and security headers. Now wrapped with the same middleware. Note: this was pre-existing from the gRPC era — the oldgrpcMuxHandleralso skipped chi middleware.authReq(LOW): Identical auth header methods insync/connectclient.goandconnector/registration.goreplaced with sharedcontrolplaneclient.ApplyAuth()SetvsAddbug (LOW): The duplicatedauthRequsedSetinside a multi-value loop. Eliminated by switching toApplyAuthwhich sets headers directly.Test plan
go build ./...passesgo vet ./...passesgo test ./... -racepasses🤖 Generated with Claude Code