Skip to main content

Migration Guide: v1.8.2

Released on 2026-11-25. Applications that leave the new setting unset retain their existing home-tenant selection. This release does not replace the v1.8.1 Cognito app-client security remediation.

Step 1: Upgrade and Keep the Opt-in Disabled​

Update every @mbc-cqrs-serverless/* package used by your application to 1.8.2 together. The following command is a core-only example; if you use master, for example, update core and master together. Domain packages can pin an exact core version, so updating only the top-level core may leave an older nested core with different tenant selection behavior.

npm install @mbc-cqrs-serverless/core@1.8.2

After updating, run npm ls @mbc-cqrs-serverless/core and verify that no older nested core versions remain. If master is already used by your application, an update command can include @mbc-cqrs-serverless/core@1.8.2 @mbc-cqrs-serverless/master@1.8.2; do not add packages that your application does not use.

By default, the JWT custom:tenant takes priority over x-tenant-code. Set EXPLICIT_TENANT_SELECTION_CODES=common to allow eligible callers to explicitly select common; use common,* to include other nonempty tenant codes. The setting defaults to empty (disabled) and is read at request time.

Step 2: Deploy Clients First​

Deploy clients that omit x-tenant-code when no tenant is selected before enabling the setting. For an eligible caller, any opted-in header is an explicit choice, including a previously hard-coded common header. A home admin with a target user role receives only the target user permissions; a home user with a target admin role receives the target admin permissions.

Step 3: Configure Selection and Verify Membership​

EXPLICIT_TENANT_SELECTION_CODES=common,*

Selection requires a nonempty direct custom:roles role for the target tenant, or system_admin in any tenant or global entry. Group membership alone and an unrelated global admin role do not qualify the caller. Route role checks still apply after tenant selection.

For an eligible explicit selection, tenantCode, tenantRole, tenantRoles and tenantGroupIds refer to the selected tenant. Only that tenant's direct roles and group IDs are used; unrelated global roles such as admin are not inherited. A system_admin entry from any scope is preserved in tenantRoles and takes priority in tenantRole. The group resolver receives the selected tenant and its groups.

Configuration entries are comma-separated, trimmed, case-insensitive and deduplicated; empty entries are ignored. Opted-in header values and matching role/group tenant codes are trimmed and lowercased. Headers outside the opt-in list keep legacy normalization.

Step 4: Verify Fallback and Denial​

RequestResolved behavior
Named target, eligible callerSelect the header tenant, even when the JWT home differs
Named target, caller not eligibleKeep the JWT home; without a home, resolve no tenant
Wildcard-selected target, caller not eligibleResolve no tenant and deny; never fall back to the home
Missing, empty or whitespace header while enabledKeep the home; without a home, deny
Literal * header while enabledReject even for system_admin

Named entries take precedence over *, regardless of configuration order. Therefore common,* preserves the named common compatibility fallback, while * alone treats common as a wildcard target and requires eligibility. RolesGuard denies unresolved tenants even on routes with no role metadata.

This opt-in is independent of COMMON_TENANT_CODES (default common) and CROSS_TENANT_ROLES (default system_admin); their defaults are unchanged. Custom guards and package policies still apply. In particular, the master package's optional access policy can independently reject no-home access to a non-common tenant even when core accepts the selection.

Test home-admin/target-user and home-user/target-admin callers, a group-only caller, a system_admin from another scope, unauthorized named and wildcard targets, empty headers and a literal wildcard. Verify both guarded routes and services that call getUserContext(); do not rely on a missing tenant being replaced by a default.

Other Fixes​

Await the CLI generation runner, isolate child-process tests, correct the JSONStream type alias and picomatch lock entry, and exclude raw EJS assets from coverage while keeping schematic implementation coverage.

See Changelog v1.8.2, authentication, environment variables, context helpers, and the still-required v1.8.1 security migration.