Skip to main content
Table of Contents

Interface ITenantScopedRequest

Namespace
Stratara.Abstractions.Multitenancy
Assembly
Stratara.Abstractions.dll

Opt-in marker for mediator requests (commands or queries) whose payload names the tenant whose data the request operates on. Implement it on a request to subject it to the tenant-isolation pipeline behavior, which rejects the request before the handler runs when TenantId does not match the current session's data-owner tenant.

public interface ITenantScopedRequest
Extension Methods

Examples

A tenant-scoped query that the isolation behavior guards:

public sealed record GetCustomerQuery(Guid CustomerId, Guid TenantId)
    : IQuery<CustomerDto>, ITenantScopedRequest;

Remarks

The behavior compares TenantId against the data-owner dimension of the ambient session (SessionContext.TenantId), not the actor dimension (SessionContext.ActorTenantId). A privileged cross-tenant operation — where the acting principal's home tenant differs from the data-owner tenant — therefore still passes the default check, because the calling endpoint is expected to have promoted the session's data-owner tenant to the target before dispatch. The optional strict mode adds an explicit authorization gate for that cross-tenant case (see the tenant-isolation behavior's options).

The marker is intentionally independent of IRequest: a request implements both its CQRS contract (ICommand/IQuery<T>) and this marker. The behavior is registered for every request shape and acts only on those that also implement ITenantScopedRequest.

Properties

TenantId

The tenant that owns the data this request operates on. Must match the current session's data-owner tenant for the request to reach its handler.

Guid TenantId { get; }

Property Value

Guid