The BitzOrcas security boundary extends beyond login. Before a request reaches a business Handler, it passes transport controls, authentication, tenant resolution, authorization, and audit. Persistence then applies tenant filters, soft-delete behavior, and concurrency checks.
TLS / Forwarded Headers / CORS / Security Headers │ ▼JWT / HMAC / API Key / SCIM Bearer authentication │ ▼current caller → tenant resolution → optional impersonation │ ▼HTTP authorization + Mediator authorization decision │ ▼data scope + ORM tenant filter + audit trailSecurity capabilities
| Topic | Question answered |
|---|---|
| Authentication | How users, application callers, and SCIM provisioners prove identity |
| Authorization | How RBAC, App Scope, ABAC, ReBAC, and Feature decisions combine |
| CORS and security headers | Browser origins, proxies, and response-header boundaries |
| Operator impersonation | Time-bounded, audited Host impersonation of users or tenants |
| Webhook signing | Integrity and replay defense for inbound/outbound webhooks |
| Two-factor authentication | TOTP, FIDO2, recovery codes, and trusted devices |
| Data protection | Key persistence, sensitive configuration, and data-at-rest protection |
| Production checklist | Configuration, key, network, and operations evidence before release |
Five boundary rules
Authentication establishes identity only
A valid JWT or matching API Key does not permit every action. Authentication builds CurrentUser with caller type, tenant, roles, permissions, or scopes. Authorization then evaluates the target resource and action.
A client cannot choose its tenant
tenant_id comes from a trusted claim, application credential, Host mapping, or controlled job scope. Headers and paths can only confirm an already-authenticated tenant. See Multitenancy deep dive.
Deny wins; absence of allow also denies
Any policy Deny blocks the request. No matching Allow also blocks it. A dependency failure must never become permission.
Secrets have no weak defaults
Missing JWT issuer, audience, or signing material stops startup. API Keys and SCIM tokens remain SHA-256 hashes at runtime. HMAC secrets still require managed configuration plus client-specific rotation and revocation.
Security operations remain traceable
Authentication failures, authorization decisions, impersonation, sensitive operations, key management, and exceptions need tenant, actual operator, CorrelationId, and TraceId. Logs never include credential plaintext.
Threats and defenses
| Threat | Main defense | Required operations control |
|---|---|---|
| Stolen JWT | Short lifetime, issuer/audience, zero ClockSkew, kid rotation | TLS, revocation policy, endpoint security |
| HMAC replay | Timestamp, nonce, method/path/query/body-hash signature | Shared Redis nonce store, secret rotation |
| Leaked API Key | Hash lookup, fixed-time comparison, tenant/scope binding | Show once, revoke, least scope |
| Cross-tenant access | Trusted resolution, resource authorization, ORM filter | Primary-key/bulk/complex-query contract tests |
| Missing permission configuration | Deny precedence, no-Allow denial, unavailable adapters | Readiness, alerting, audit monitoring |
| Browser cross-origin calls | Token auth, CORS, security headers | Exact origin list, TLS, frontend storage policy |
When developing a feature
- Declare resource and action on the Command/Query instead of scattering checks in the Handler.
- Obtain caller and tenant from trusted context, not ownership fields in a DTO.
- Apply
DataScopeto list reads in addition to the ORM tenant filter. - Define redaction for secrets, tokens, personal data, and sensitive business fields.
- Test anonymous, denied, cross-tenant, expired-impersonation, unavailable-dependency, and cache-invalidation paths.
How to read this section
Start with authentication and authorization to establish caller, resource, and action semantics, then study the browser/proxy boundary and Data Protection. Use the delegation, MFA, and Webhook chapters for those flows, and finish with the production evidence checklist. Every page distinguishes shipped primitives, Host composition responsibility, and work an adopting business module must still complete.
- 01/14
Modern Multi-Tenant Authentication: JWT, API Keys, and Context Injection
Explore the BitzOrcas.Modern authentication core. Learn ClaimsPrincipal resolution, high-throughput API Key validation, and immutable ICurrentUser / ICurrentTenant scoped injection.
- 02/14
Fine-Grained Resource-Action Authorization: IAuthorizedRequest Guide
Say goodbye to hardcoded role explosion! Master the BitzOrcas.Modern Resource-Action authorization model with IAuthorizedRequest contracts and dynamic evaluation.
- 03/14
CORS, trusted proxies, and security headers
Configure and verify browser origins, trusted proxy topology, and defensive response headers at the API boundary.
- 04/14
Data Protection and shared key rings
Understand purpose isolation, the Redis key repository, fallback behavior, rotation, and rolling-deployment proof.
- 05/14
Secrets, signing keys, and license material
Manage JWT, HMAC, Webhook, databases, object storage, OAuth, Data Protection, and runtime-license material through a complete lifecycle.
- 06/14
Multi-factor authentication and risk challenges
Explain the real TOTP login flow, FIDO2, email/SMS OTP, recovery codes, trusted devices, and risk policy boundaries.
- 07/14
Sensitive Operation Re-authentication (Step-Up)
Login MFA cannot answer “is it still you right now?”. Step-Up re-authentication verifies identity per sensitive operation: one global enforcement middleware, a three-layer policy model, and six factors reusing existing verification kernels.
- 08/14
Step-Up Quickstart
Wire a business endpoint into sensitive-operation re-authentication through three paths: zero-code policy rows from the admin page, a [RequireStepUp] declared baseline, and one-shot tickets for money-moving operations — with staged verification points and expected failures.
- 09/14
Step-Up Contract Reference
Every public surface of sensitive-operation re-authentication: ten endpoints, challenge and verification JSON contracts, three 403 ProblemDetails shapes, the full error table, and StepUpOptions keys — each verified against source.
- 10/14
Step-Up Frontend Integration
How the first-party SPA implements the re-authentication protocol: the four interceptor replay rules, the verification dialog state machine, the memory-only credential red line, and SDK usage. Business code stays unaware.
- 11/14
Step-Up Rollout and Operations
The AuditOnly-first rollout order, threshold tuning guidance, runbook essentials, and three canonical troubleshooting paths: Redis unavailability, missing-version-key alerts, and rising GrantPurposeMismatch counts.
- 12/14
User delegation and tenant impersonation
Distinguish same-tenant user impersonation from cross-tenant Tenant Impersonation across direct issue, TabScoped/SiteWide handoff, active revocation, sensitive operations, and audit.
- 13/14
Webhook signing, replay defense, and idempotent consumption
Implement the current HMAC-SHA256 contract and add timestamp, event deduplication, rotation, and failure evidence.
- 14/14
Production security checks and delivery evidence
Complete production acceptance with startup guards, negative contracts, attack-boundary tests, and recovery rehearsals.