Skip to content
bitzorcas
中EN

Recipe

Practical Guide: Operator Impersonation & Security Audit

Master operator impersonation in BitzOrcas.Modern: short-lived dual-identity JWTs, DelegatedSessionRestrictionPipelineBehavior sensitive operation blocks, and immutable dual-identity audits.

Last updated

When law firm tenants encounter complex domain issues requiring platform support engineers to assist remotely, traditional workarounds—such as asking customers for their plaintext passwords or connecting directly to production databases—introduce catastrophic data compliance liabilities and legal exposure.

BitzOrcas.Modern incorporates an industrial-grade Operator Impersonation Sandbox Architecture:

  1. Dual-Identity JWTs: Dispatched only after formal support ticket approval, carrying both the real actorid (support operator) and target sub (impersonated tenant user), with a strictly capped 15-minute lifespan;
  2. Fail-Closed Sensitive Operation Sandbox: Stage 3 in the application pipeline (DelegatedSessionRestrictionPipelineBehavior) automatically blocks any request marked with IDelegationSensitiveRequest (such as password changes, MFA updates, and API key generation);
  3. Immutable Dual-Identity Auditing: Every business operation automatically records both the acting operator and the target customer context in the persistent audit envelope.

This guide details token issuance, pipeline enforcement, and audit persistence for operator impersonation.

Dual-Identity Impersonation Sequence

"SQL Server 2022""Stage 9 Audit Pipeline (AuditBehavior)""10-Stage Pipeline (Stage 3 DelegatedSession)""API Host (:6881)""YARP Gateway (:6880)""SQL Server 2022""Stage 9 Audit Pipeline (AuditBehavior)""10-Stage Pipeline (Stage 3 DelegatedSession)""API Host (:6881)""YARP Gateway (:6880)"If message implements IDelegationSensitiveRequest, reject with 403 Forbidden!"Platform Support Operator"1. POST /api/identity/impersonation/start (Ticket ID & Target Tenant)12. Forward request23. Issue 15-min dual-identity JWT (actorid + sub)34. Dispatch business operation or sensitive request (impersonation JWT)45. Forward request to 10-stage pipeline56. DelegatedSessionRestrictionPipelineBehavior intercepts67. Allow legitimate query/command and capture dual identities78. Persist immutable audit log: OperatorId=OPS-001, TenantId=lawfirm-alpha, UserId=USR-ALICE8"Platform Support Operator"

Step 1: Request and Issue Short-Lived Dual-Identity JWT

Platform support personnel initiate an impersonation session from the SaaS Host management console:

Platform operator initiates impersonation session
# 1. Provide platform admin bearer token
# 2. Request a 15-minute dual-identity credential for target tenant user
curl -X POST http://localhost:6881/api/identity/impersonation/start \
-H "Authorization: Bearer YOUR_PLATFORM_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"targetTenantId": "lawfirm-alpha",
"targetUserId": "USR-ALICE",
"ticketNumber": "TICKET-2026-88902",
"reason": "Investigate matter litigation stage advancement failure",
"durationMinutes": 15
}'

The resulting JWT carries authoritative dual-identity claims:

  • sub: USR-ALICE (impersonated tenant user ID)
  • tenant: lawfirm-alpha (target tenant ID)
  • actortype: PlatformOperator (impersonation principal type)
  • actorid: OPS-001 (actual support operator identifier for audit attribution)

Step 2: Pipeline Interception (DelegatedSessionRestrictionPipelineBehavior)

At Stage 3 of the 10-stage execution pipeline, DelegatedSessionRestrictionPipelineBehavior enforces fail-closed isolation. Any message implementing IDelegationSensitiveRequest (such as password resets, MFA enrollment, or API token generation) is immediately rejected:

src/Framework/BitzOrcas.Application/Pipelines/DelegatedSessionRestrictionPipelineBehavior.cs
using System.Threading;
using System.Threading.Tasks;
using BitzOrcas.Application.Abstractions;
using BitzOrcas.Domain.Results;
using Mediator;
namespace BitzOrcas.Application.Pipelines;
/// <summary>
/// Rejects credential, password, and MFA mutation requests when executed under an impersonated session
/// </summary>
/// <typeparam name="TMessage">Message type implementing the sensitive marker interface.</typeparam>
/// <typeparam name="TResponse">Result response type capable of constructing failures.</typeparam>
public sealed class DelegatedSessionRestrictionPipelineBehavior<TMessage, TResponse>(
ICurrentUser currentUser)
: IPipelineBehavior<TMessage, TResponse>
where TMessage : IMessage, IDelegationSensitiveRequest
where TResponse : IResult<TResponse>
{
/// <summary>
/// Passes standard requests, while failing closed for impersonated sessions
/// </summary>
public async ValueTask<TResponse> Handle(
TMessage message,
MessageHandlerDelegate<TMessage, TResponse> next,
CancellationToken cancellationToken)
{
// Core security invariant: block sensitive credential changes during impersonation
if (currentUser.User.IsImpersonating)
{
return TResponse.Failure(
ApplicationErrors.Authorization.DelegatedSensitiveOperationDenied);
}
return await next(message, cancellationToken);
}
}

Step 3: Immutable Dual-Identity Audit Persistence

When permitted operations execute within an impersonated session, Stage 9 of the pipeline captures both identities in the audit log:

Sample audit log record
{
"auditId": "AUDIT-20260923-008821",
"tenantId": "lawfirm-alpha",
"userId": "USR-ALICE",
"isImpersonated": true,
"operatorId": "OPS-001",
"action": "legal.matters.advance-stage",
"resource": "MAT-2026-0001",
"ipAddress": "192.168.1.102",
"userAgent": "Mozilla/5.0 BitzOrcas/Modern OperatorConsole",
"timestampUtc": "2026-09-23T04:20:00Z"
}

Summary

The Operator Impersonation sandbox enforces rigorous security guarantees:

  • Zero Plaintext Credentials: Operators never handle customer passwords; sessions expire automatically after 15 minutes;
  • Sensitive Operations Immune to Tampering: IDelegationSensitiveRequest contracts fail-closed at Stage 3 of the pipeline;
  • Complete End-to-End Attribution: Dual-identity claims span logs and database audits, ensuring all operator actions are 100% auditable.

100%

Scroll or use controls to zoom · drag when enlarged · double-click for 100% / 200%