Skip to content

fix: tenant membership on ledger invite + service auth#1680

Merged
popmechanic merged 4 commits intoselem/docker-for-allfrom
fix/redeem-invite-tenant-and-service-auth
Mar 10, 2026
Merged

fix: tenant membership on ledger invite + service auth#1680
popmechanic merged 4 commits intoselem/docker-for-allfrom
fix/redeem-invite-tenant-and-service-auth

Conversation

@popmechanic
Copy link

Summary

  • redeemInvite tenant fix: When redeeming a ledger invite, also add the user to the ledger's parent tenant via addUserToTenant. Without this, ensureCloudToken produces a cloud token where selected.tenant isn't in tenants[], and the Cloud Backend rejects all data operations.

  • Service auth: Add ServiceApiToken class for machine-to-machine API calls. Uses compound token format (key|providerUserId|email). Opt-in via SERVICE_API_KEY env var. Needed by the VibesOS Deploy API to create Connect invites for public link sharing.

Test plan

  • Existing tests pass unchanged
  • New test: ledger invite redemption creates both LedgerUsers and TenantUsers rows
  • New test: ensureCloudToken succeeds after ledger invite redemption (selected.tenant in tenants[])
  • New test: service auth accepted with valid key
  • New test: service auth rejected with wrong key

Note: Pre-existing failure in "email-invite auto-redeemed on ensureUser" is unrelated (MAX_MEMBER_USERS limit hit from other tests in the suite).

redeemInvite adds users to LedgerUsers but not TenantUsers for ledger
invites. This test verifies that after redemption, the user has tenant
membership and ensureCloudToken produces a valid token.
redeemInvite called addUserToLedger but not addUserToTenant for
ledger invites. The cloud backend's ensureTenantLedger validation
requires selected.tenant to be in the token's tenants array, which
only includes tenants with a TenantUsers row.
Promotes svc to describe scope and adds SERVICE_API_KEY to test env.
Adds two tests: valid service auth (fails - type not recognized) and
wrong key rejection (passes with existing error behavior).
Adds ServiceApiToken with compound token format (key|providerUserId|email).
Opt-in via SERVICE_API_KEY env var. Enables external services like
the Deploy API to call inviteUser without an OIDC token.

- ServiceApiToken class in core/protocols/dashboard/token.ts
- "service" type added to DashAuthType union
- "service" case in coercedVerifiedAuthUser
- Tests: valid service auth + wrong key rejection
@popmechanic popmechanic merged commit 3d3d801 into selem/docker-for-all Mar 10, 2026
1 check passed
@popmechanic popmechanic deleted the fix/redeem-invite-tenant-and-service-auth branch March 10, 2026 01:16
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