Skip to content

feat(api): add CreateOrganizationResource - #1987

Merged
AmanGIT07 merged 1 commit into
mainfrom
feat/create-organization-resource
Oct 16, 2026
Merged

AmanGIT07 merged 1 commit into
mainfrom
feat/create-organization-resource

Conversation

@AmanGIT07

@AmanGIT07 AmanGIT07 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

CreateOrganizationResource creates a resource that belongs to an organization and not to a project. Project and organization resources share one create path. Stacked on #1986.

Changes

  • resource.Service.Create looks up the parent once with getParent: the organization when the resource has one and no project, else the project. One path then saves the row, links the parent in SpiceDB, adds the owner, and writes the resource.created audit record, which names the project or the organization.
  • An organization resource's URN is frn:<org id>:<namespace>:<name>.
  • resource.Service.Delete uses the same lookup, so its audit record works for both kinds.
  • addParentToResource replaces AddProjectToResource, which only Create used.
  • CreateProjectResource and CreateOrganizationResource share createResource in the handler. CreateProjectResource keeps its project lookup, responses, and error messages.
  • CreateOrganizationResource returns not found for a missing organization.
  • The authorization rule checks get on the organization, then the plan entitlement, as CreateProjectResource does on the project.
  • getParent and the plan entitlement check read the organization with GetRaw. A disabled organization is then handled only by the organization state check in IsAuthorized: callers get failed precondition, and a platform superuser skips it, as on project resources.
  • Resource responses include org_id.

Technical Details

  • The proto requires org_id to be a UUID, so an organization name is not accepted.
  • No rule ran the plan entitlement check on an organization before this one, so the GetRaw change does not touch existing RPCs.

Test Plan

  • go test ./core/resource/ passes. New cases: the organization path (URN, organization link, owner, audit record naming the organization), a failed organization lookup that creates nothing, the exact project link and project audit record on create, and deleting an organization resource.
  • go test ./internal/api/v1beta1connect/ passes, with the CreateProjectResource cases unchanged. New TestConnectHandler_CreateOrganizationResource: missing body, missing organization, bad detail, conflict, internal error, and success with org_id and no project. New TestCheckPlanEntitlement: a disabled organization passes.
  • e2e TestResourceAPI case 5: a member creates a resource; the response has the organization, no project, and the URN; the creator can update it and another member cannot; creating it again returns the same id; after the organization is disabled, the member gets failed precondition and a platform superuser still creates one. With either GetRaw back to Get, the superuser's create fails.
  • e2e TestPATScope_AllProjectsDoesNotReachOrgResources: a token scoped to all projects can update a resource in a project and cannot update a resource owned by the same organization. The PAT suite now seeds the compute permissions.
  • go test ./test/e2e/... passes.
  • golangci-lint run reports no issues.

@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Oct 16, 2026 8:25am UTC

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: raystack/frontier/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fa3acf00-6f2b-4e26-b441-4fce32fe7d8f
📥 Commits

Reviewing files that changed from the base of the PR and between 281fa33 and 89ddff6.

📒 Files selected for processing: 10
  • core/resource/resource.go
  • core/resource/service.go
  • core/resource/service_test.go
  • internal/api/v1beta1connect/authorize.go
  • internal/api/v1beta1connect/authorize_test.go
  • internal/api/v1beta1connect/resource.go
  • internal/api/v1beta1connect/resource_test.go
  • pkg/server/connect_interceptors/authorization.go
  • test/e2e/regression/api_test.go
  • test/e2e/regression/pat_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

coveralls commented Oct 13, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 38873543560

Coverage increased (+0.07%) to 55.058%

Details

  • Coverage increased (+0.07%) from the base build.
  • Patch coverage: 25 uncovered changes across 3 files (106 of 131 lines covered, 80.92%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
pkg/server/connect_interceptors/authorization.go 12 0 0.0%
internal/api/v1beta1connect/resource.go 70 60 85.71%
core/resource/service.go 46 43 93.48%
Total (5 files) 131 106 80.92%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 41618
Covered Lines: 22914
Line Coverage: 55.06%
Coverage Strength: 19.08 hits per line

💛 - Coveralls

@AmanGIT07
AmanGIT07 force-pushed the feat/org-resource-schema branch from 2a1b47f to a54c5a7 Compare October 13, 2026 06:18
@AmanGIT07
AmanGIT07 force-pushed the feat/create-organization-resource branch from c537a75 to cd7d96c Compare October 13, 2026 06:19
@AmanGIT07
AmanGIT07 force-pushed the feat/org-resource-schema branch from a54c5a7 to 00bb31e Compare October 13, 2026 06:20
@AmanGIT07
AmanGIT07 force-pushed the feat/create-organization-resource branch from cd7d96c to a19eaf4 Compare October 13, 2026 06:21
@AmanGIT07
AmanGIT07 marked this pull request as draft October 13, 2026 07:15
@AmanGIT07
AmanGIT07 force-pushed the feat/create-organization-resource branch from a19eaf4 to 720735f Compare October 13, 2026 07:28
@AmanGIT07
AmanGIT07 marked this pull request as ready for review October 13, 2026 07:42
@AmanGIT07
AmanGIT07 force-pushed the feat/org-resource-schema branch from 00bb31e to f713892 Compare October 13, 2026 08:26
@AmanGIT07
AmanGIT07 force-pushed the feat/create-organization-resource branch from 720735f to 3e237c1 Compare October 13, 2026 08:26
@AmanGIT07
AmanGIT07 force-pushed the feat/create-organization-resource branch from 3e237c1 to 88e94de Compare October 13, 2026 09:44
@AmanGIT07

Copy link
Copy Markdown
Contributor Author

End to end against a local server, with Postgres and SpiceDB in Docker. The binary under test is the whole stack (#1985, #1986, #1987, #1989, #1990, #1991). The main column ran the same checks with the main binary on the same database. On main the new RPCs are in the proto but have no handler, so the interceptor denies them.

Check main this stack
Create an org resource as an org member permission denied ok
Response org_id is the org, project_id empty, URN frn:<org id>:orgres/store:store-1, principal is the caller
Create it again with the same name ok, same id
Caller is not an org member permission denied
Org id is not a uuid invalid argument
Org id does not exist permission denied
Unknown namespace invalid argument
Relations written org to the org, owner to the caller
resource.created audit record names the org
Disabled org: create as a member failed precondition
Disabled org: create as a platform admin ok

CreateProjectResource now shares the create path:

Check main this stack
Create a project resource ok ok, response has the project's org_id
Get and list project resources ok ok, each has the project's org_id
Relations written owner, project owner, project
resource.created audit record names the project names the project
Create it again with the same name ok, same id, 2 audit records ok, same id, 2 audit records
Unknown namespace invalid argument invalid argument
Disabled org: create as the org owner failed precondition failed precondition
Disabled org: create as a platform admin ok ok

@rohilsurana rohilsurana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Four questions inline. One is about the re-create path, which was already like this for project resources. The other three are about how the project RPCs and the disabled org gate treat an org resource. None of them are about who may call the new RPC.

Comment thread core/resource/service.go Resolved
Comment thread internal/api/v1beta1connect/resource.go Resolved
Comment thread internal/api/v1beta1connect/resource.go Resolved

@rohilsurana rohilsurana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My open questions are all tracked now (#2001, #2002), and the disabled org gate is fixed in #1990. Approving.

@AmanGIT07
AmanGIT07 force-pushed the feat/org-resource-schema branch from f713892 to a6f7b49 Compare October 16, 2026 08:18
@AmanGIT07
AmanGIT07 force-pushed the feat/create-organization-resource branch from 88e94de to 57293d0 Compare October 16, 2026 08:18
Base automatically changed from feat/org-resource-schema to main October 16, 2026 08:23
Create a resource that belongs to an organization: the URN uses the organization id, SpiceDB links the resource to the organization, and the audit record names the organization. Project and organization resources share one create path in the service and in the handler. Callers need get on the organization; a missing organization returns not found and a disabled one failed precondition. Resource responses now include org_id.
@AmanGIT07
AmanGIT07 force-pushed the feat/create-organization-resource branch from 57293d0 to 89ddff6 Compare October 16, 2026 08:25
@AmanGIT07
AmanGIT07 merged commit 4770ecb into main Oct 16, 2026
7 of 8 checks passed
@AmanGIT07
AmanGIT07 deleted the feat/create-organization-resource branch October 16, 2026 08:29

This branch was successfully deployed

1 active deployment
Preview — 89ddff6f Deployed Oct 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants