feat(tenants): finish PMS-21 story (TenantScope extractor, feature-gate /tenants) #23
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/tenants-story-pms-21"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements YouTrack story PMS-21 (tenants + multi-tenancy enforcement). One commit per sub-task.
Sub-tasks
tenants/routes.rs(GET + PUT/api/v1/tenants/:tenant_id/modules/:module); closed administratively.TenantScope { tenant_id, user }FromRequestPartsextractor that hard-binds tenant id to the authenticated caller's claim, so handlers stop copy-pastinguser.tenant_idby hand. ExistingRequireAuthcallsites can migrate incrementally; new handlers should takescope: TenantScope..nest("/tenants", ...)andTenantService::neware only built under#[cfg(feature = "multi-tenant")]. Verified both--features multi-tenant(default) and--no-default-features --features single-tenant,servercompile clean.Behaviour-visible changes
/api/v1/tenants/*continues to work./api/v1/tenants/*now returns the global fallback (HTML "this is an API endpoint") because the route is absent. Operators of single-tenant deployments no longer have a tenant-CRUD foot-gun.Test plan
cargo check --bin mokosh-serverclean (verified locally, both feature configurations).GET /api/v1/tenants/:id/modules/:modulereturns expected JSON for a known tenant + module.--no-default-features --features single-tenant,server;/api/v1/tenants/*404s.Closes #PMS-21
The `multi-tenant` / `single-tenant` cargo features have existed in `AppConfig::is_multi_tenant` since day one but were inert at the routing layer — both builds exposed `/api/v1/tenants/*`. In a single-tenant deployment that's a foot-gun: a CRUD endpoint that can spawn extra tenant rows breaks the deployment's load-bearing assumption. Now `.nest("/tenants", ...)` is only added under `#[cfg(feature = "multi-tenant")]`, and `TenantService` is constructed only in that mode. Verified both `--features multi-tenant` (default) and `--no-default-features --features single-tenant,server` builds compile clean. #PMS-24 State DonePull request closed