Skip to content

feat: add Cloudflare Organization support - #52

Open
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
feat/organization-support
Open

feat: add Cloudflare Organization support#52
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
feat/organization-support

Conversation

@c1-dev-bot

@c1-dev-bot c1-dev-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

Summary

Adds support for Cloudflare's new Organizations feature. When an optional --organization-id parameter is provided, the connector syncs the organization as a group resource and creates membership grants linking users to the organization.

This solves the problem where users running separate connectors per Cloudflare account have no way to distinguish which users belong to which organization, and built-in roles appear duplicated across accounts.

Fixes: CXH-1988

Changes

  • Config: Added optional --organization-id field to both authentication groups (API Token and API Key + Email)
  • Organization resource type: New organization resource with TRAIT_GROUP trait
  • Organization syncer (organization.go): Uses raw HTTP calls to the Cloudflare Organizations API (Public Beta) since the cloudflare-go v0 SDK does not expose these endpoints
    • List() fetches the organization details via GET /organizations/{id}
    • Entitlements() exposes a "member" entitlement per organization
    • Grants() lists organization members via GET /organizations/{id}/members with pagination
  • Connector: Conditionally registers the organization syncer only when organization-id is configured

Notes

  • The Cloudflare Organizations API is in Public Beta — the read endpoints used here (get org, list members) are available, but write endpoints (create membership) are in Closed Beta
  • Uses the same raw HTTP pattern as api_token.go and invitation.go for SDK-unsupported endpoints
  • The organization syncer only syncs active members (skips canceled/inactive)
  • The --organization-id parameter is fully optional — existing deployments without it continue to work unchanged

Test plan

  • go build ./cmd/baton-cloudflare/ succeeds
  • go test ./... passes
  • Manual testing with a Cloudflare account that has Organizations enabled
  • Verify organization appears as a group resource in sync output
  • Verify organization membership grants link users to the organization

Automated PR Notice

This PR was automatically created by c1-dev-bot as a potential implementation.

This code requires:

  • Human review of the implementation approach
  • Manual testing to verify correctness
  • Approval from the appropriate team before merging

Add an optional --organization-id configuration parameter. When set,
the connector syncs the Cloudflare organization as a group resource and
creates membership grants linking users to the organization.

This allows customers using Cloudflare's new Organizations feature to
see which users belong to which organization, solving the problem of
running separate connectors per account with no way to distinguish
user-to-organization membership.

Uses raw HTTP calls to the Cloudflare Organizations API (Public Beta)
since the cloudflare-go v0 SDK does not expose these endpoints.
@c1-dev-bot
c1-dev-bot Bot requested a review from a team July 6, 2026 15:04
@linear-code

linear-code Bot commented Jul 6, 2026

Copy link
Copy Markdown

CXH-1988

Comment on lines +220 to +233
for _, member := range resp.Result {
if member.Status != "active" {
continue
}
if member.User.ID == "" {
continue
}

userResourceId := &v2.ResourceId{
ResourceType: resourceTypeUser.Id,
Resource: member.User.ID,
}

rv = append(rv, grant.NewGrant(resource, orgMemberEntitlement, userResourceId))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: A Cloudflare organization can span multiple accounts, so /organizations/{id}/members may return users who are not synced by this connector instance (which only syncs members of the single configured account-id). Those member grants will reference user resources that don't exist in this sync and become dangling. Consider whether this is intended (grants resolved cross-connector by C1) or whether org members should be reconciled against the synced user set. (Confidence: medium)

@laurenleach laurenleach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should update the default capabilities builder so that we include the org syncer for our generated capabilities

example: https://github.com/ConductorOne/baton-aws/blob/main/pkg/connector/connector.go#L474-L499

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.

1 participant