Repository navigation
feat(store): org service user credentials search skips soft-deleted rows - #1949
Conversation
The search reads credentials and service users through the live-row helpers, and joins organizations so a soft-deleted org reports nothing, the same as an org id nobody owns.
…deleted rows Seeds a revoked credential, a credential of a soft-deleted service user, and one under a soft-deleted organization, then checks the listing and the text search.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: raystack/frontier/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe service-user credential query now uses live credentials, joins organizations through the service user’s organization ID, and excludes soft-deleted service users and organizations. SQL expectations and PostgreSQL tests cover the filters. ChangesCredential Search
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No actionable issue remains identified for this change; it is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The search now hides revoked credentials and credentials associated with deleted service users or organizations. The organization restriction remains in place, and the change does not grant new access. Some end-to-end security behavior remains unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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 |
Sixth of the org view repositories. Follows #1946 and #1947.
Summary
The organization service user credentials search leaves out revoked credentials, soft-deleted service users, and soft-deleted organizations.
Changes
fromLive(serviceuser_credentials)and addsliveon the joined service users.liveon it, so a soft-deleted organization reports no credentials.org_serviceuser_credentials_repository_pg_test.go: seeds a revoked credential, a credential whose service user is soft-deleted, and one under a soft-deleted organization, then checks the listing and the text search.Technical Details
The organization id arrives as a request parameter and only scoped the service users. Without the join, a soft-deleted organization still returned its credentials while an org id nobody owns returned nothing. The join makes those two agree.
This RPC authorizes with
IsSuperUser, so the disabled-organization gate inIsAuthorizednever runs on it, and that gate steps aside for platform superusers in any case. The check therefore has to live in the query.The join is on the organizations primary key, so it matches at most one row and cannot duplicate credentials.
Frontier does not set
deleted_aton these tables yet, so the search returns the same rows as before.Test Plan
go test -run 'TestOrgServiceUserCredentials' ./internal/store/postgres/passes (unit tests and the new suite)maingolangci-lint run ./internal/store/postgres/...reports no issuesAdminService/SearchOrganizationServiceUserCredentials. Two orgs, three service users and four credentials were created through the public RPCs, thendeleted_atwas set by SQL. The same scenarios ran againstmainon the same database, with only the binary swapped.SQL Safety
?placeholders,goqu.Ex{}, orgoqu.Record{}— neverfmt.Sprintfor+building a query that gets executed.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L.//nolint:forbidigoor// #nosec G20xannotations.