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
Default behaviour is Actor = Subject — UserPlatform users operate on their own tenant's data. PlatformAdmin 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
nextRequestDelegateoptionsIOptions<SessionContextOptions>
Remarks
Default behaviour is Actor = Subject — UserPlatform users operate on their own tenant's data. PlatformAdmin 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
httpContextHttpContextThe current request's HttpContext.
sessionContextProviderISessionContextProviderThe ambient session-context provider (DI-resolved per request).