Skip to main content
Table of Contents

Class SessionContextMiddleware

Namespace
Stratara.Sessions.Middlewares
Assembly
Stratara.Sessions.dll

ASP.NET Core middleware that populates the ambient ISessionContextProvider from the incoming request's JWT claims. For unauthenticated requests the middleware leaves the provider untouched.

public sealed class SessionContextMiddleware
Inheritance
SessionContextMiddleware
Inherited Members
Extension Methods

Remarks

The actor tenant and the data-owner tenant are the claimed tenant, the claimed user is the actor user, and UserId is left unset: the scope a protected field is encrypted under follows the data owner, so filling in the user would move every protected field written from a request to a per-user scope. Endpoints that act on a foreign tenant override TenantId after authorization.

The X-Tenant-Id HTTP header is honoured as a fallback for the tenant claim only when AllowTenantHeader is set to true. The default since 3.0.10 is fail-closed: a missing or unparsable claim resolves to Value regardless of the header. See Round-3-Audit Finding KI-04 for the threat model.

Constructors

SessionContextMiddleware(RequestDelegate, IOptions<SessionContextOptions>)

ASP.NET Core middleware that populates the ambient ISessionContextProvider from the incoming request's JWT claims. For unauthenticated requests the middleware leaves the provider untouched.

public SessionContextMiddleware(RequestDelegate next, IOptions<SessionContextOptions> options)

Parameters

next RequestDelegate
options IOptions<SessionContextOptions>

Remarks

The actor tenant and the data-owner tenant are the claimed tenant, the claimed user is the actor user, and UserId is left unset: the scope a protected field is encrypted under follows the data owner, so filling in the user would move every protected field written from a request to a per-user scope. Endpoints that act on a foreign tenant override TenantId after authorization.

The X-Tenant-Id HTTP header is honoured as a fallback for the tenant claim only when AllowTenantHeader is set to true. The default since 3.0.10 is fail-closed: a missing or unparsable claim resolves to Value regardless of the header. See Round-3-Audit Finding KI-04 for the threat model.

Methods

InvokeAsync(HttpContext, ISessionContextProvider)

Process a single request: parse identity claims and set the session context.

public Task InvokeAsync(HttpContext httpContext, ISessionContextProvider sessionContextProvider)

Parameters

httpContext HttpContext

The current request's HttpContext.

sessionContextProvider ISessionContextProvider

The ambient session-context provider (DI-resolved per request).

Returns

Task