Skip to content

feat(sharing): authorize identity-owned device invites#1360

Merged
kunickiaj merged 1 commit into
mainfrom
07-25-feat_sharing_authorize_identity-owned_device_invites-v2
Jul 25, 2026
Merged

feat(sharing): authorize identity-owned device invites#1360
kunickiaj merged 1 commit into
mainfrom
07-25-feat_sharing_authorize_identity-owned_device_invites-v2

Conversation

@kunickiaj

@kunickiaj kunickiaj commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Description

Allow an enrolled device to create an add-device invitation for its own coordinator-bound Identity without possessing the coordinator admin secret.

The new fixed-purpose signed endpoint derives the target Identity exclusively from the active enrollment binding, verifies the reviewed intent and digest against that Identity, rejects authority fields supplied by the client, and uses existing signature/nonce replay protection. Team invitation creation remains admin-only. An explicitly admin-configured initial owner continues to select admin issuance up front because initial owner enrollment intentionally remains unbound; signed failures never fall back to admin authorization.

This prevents a teammate from selecting another Identity or using a broad admin credential merely to add one of their own devices.

Type of Change

  • 🚀 Feature (new functionality)
  • 🐛 Bug fix (fixes an issue)
  • 📚 Documentation (docs-only change)
  • 🔧 Maintenance (refactor, chore, CI, etc.)
  • 🧪 Testing (test-only changes)

Testing

  • Relevant checks pass locally (pnpm run tsc, pnpm run lint, pnpm run test)
  • Added/updated tests for changes
  • Manually verified changes work as expected

Additional validation:

  • pnpm --filter @codemem/cloudflare-coordinator-worker test:worker
  • Real Worker/D1 coverage for unknown, unbound, disabled, invalid-signature, cross-Identity, Team-intent, forbidden-field, success, and replay cases
  • Independent security/correctness, test-coverage, and maintainability reviews

Checklist

  • Code follows project style (pnpm run lint passes for touched files)
  • Self-review completed
  • Documentation updated (if needed)
  • No new warnings introduced

Copy link
Copy Markdown
Owner Author

@kunickiaj

Copy link
Copy Markdown
Owner Author

Recreates #1358, which GitHub auto-closed when its base branch was deleted during the #1357 merge. Identical diff, rebased onto main. All review context: #1358.

@kunickiaj
kunickiaj marked this pull request as ready for review July 25, 2026 15:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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.

Reviewed commit: ab64d8d239

ℹ️ 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".

reviewed_preview_digest: reviewedPreviewDigest,
reviewed_intent: opts.reviewedIntent,
};
const url = `${stripTrailingSlashes(remote)}/v1/invites/add-device`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize the coordinator URL before signing

For a scheme-less coordinator configuration such as coord.example:7337, regular coordinator presence and peer lookup work because coordinator-runtime.ts passes syncCoordinatorUrl through buildBaseUrl, but this new path constructs coord.example:7337/v1/invites/add-device directly. buildAuthHeaders consequently parses coord.example: as a non-HTTP scheme and fetch fails with an unknown-scheme error, so non-admin add-device invitations fail for an otherwise working coordinator configuration. Build the request URL from buildBaseUrl(remote) before signing and sending it.

Useful? React with 👍 / 👎.

kunickiaj commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

Merge activity

  • Jul 25, 3:10 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 25, 3:10 PM UTC: @kunickiaj merged this pull request with Graphite.

@kunickiaj
kunickiaj merged commit a163fa5 into main Jul 25, 2026
13 checks passed
@kunickiaj
kunickiaj deleted the 07-25-feat_sharing_authorize_identity-owned_device_invites-v2 branch July 25, 2026 15:10
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