* Implement tenant and user creation in IdentityPage * Add API calls for managing tenants and users * Introduce tenant-scoped API requests * Update sidebar to include identity navigation * Create BooleanStatusBadge component for key status
2.1 KiB
Tenant identity management
The previous tenancy implementation used every API-key ID as its tenant key. This meant that two keys could not share data and old unscoped rows could not be reached by any key after tenancy was enabled.
Implemented a separate tenant mapping: configured and managed API keys now resolve to an assigned tenant ID, while unassigned configured keys retain their historical key-ID tenant boundary for compatibility. Added tenant, tenant-user, key-assignment, and managed-secret records, with a one-time, explicit legacy adoption endpoint that assigns only NULL tenant-key rows to a selected tenant.
The admin UI now has an Identity page for tenants, users, configured-key assignment, managed-key creation (secret shown once), disabling keys, and legacy adoption. Managed secrets are stored only as SHA-256 hashes. The AMCS MCP capture-thought tool was unavailable in this session, so this local log is the required fallback summary.
Configured keys also accept an optional auth.keys[].tenant_id. This supplies the initial tenant boundary at startup; an explicit assignment saved through the Identity UI overrides it.
Tenant-owned root records now reference tenants(id) through tenant_id; tenant scoped resources include skills, guardrails, personas, parts, traits, and character arcs. Tenant-selection in the UI is sent as X-AMCS-Tenant-ID for admin/ResolveSpec requests.
With explicit approval that tenancy data is disposable, the compatibility migration now renames the ownership column from tenant_key to tenant_id across the historical migration chain.
Tenant selection now centrally filters every tenant-owned ResolveSpec read, update, and delete in the admin UI, and injects the selected tenant_id on create requests.
Identity mutations now require a configured API key with superadmin: true; tenants themselves remain database-managed.
Fixed the admin sidebar tenant-scope selector flicker. Its focus handler reloaded the tenant list and disabled the native select while its picker was opening; tenants now load on sidebar mount only, so a selection remains open and usable. Validated with pnpm check (0 errors, 0 warnings).