Fix CodeRouter trusted tenant exchange
Merged
LA
3mo ago+65+65+01234567890123456789-5-5-0123456789
Moves the trusted hosted-tenant exchange request into the API route so the deployed function always sends the scoped capabilities and dedicated control credential. This fixes production CLI login failures caused by a stale bundled hosted client omitting the control header.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Moves the trusted hosted-tenant exchange into API routes and switches the CLI to a semantic endpoint. Always forwards scoped capabilities and the stack control token header to fix login failures from stale clients.
- Bug Fixes
- Added
POST /api/subrouter/tenant-exchangethat posts to/_subrouter/auth/stackwithAuthorization,x-subrouter-stack-control-token, capability flags, and team info; uses no-store caching, propagates upstream errors, and returns parsed tenant JSON. - Updated CLI config to set
exchangeUrlto/api/subrouter/tenant-exchangeandcache-controltono-storeon the config response. - Read hosted credentials via validated
env(SUBROUTER_HOSTED_URL,SUBROUTER_STACK_TENANT_DELETE_TOKEN); return 503 if missing.
- Added
Summary by CodeRabbit
-
New Features
- Added tenant-aware subrouter exchange support for CLI integrations.
- Tenant capabilities and identity are securely forwarded during exchanges.
- Added permission checks and validation for required service configuration.
-
Bug Fixes
- Updated CLI configuration to use the tenant-specific exchange endpoint.
- Improved propagation of upstream errors and unexpected failures.
- Exchange responses are now uncached to ensure current configuration is used.