Skip to main content
Table of Contents

Class MembershipClaimsPrincipalFactory<TUser>

Namespace
Stratara.Identity.AspNetCore.Services
Assembly
Stratara.Identity.AspNetCore.dll

Decorates the host's IUserClaimsPrincipalFactory<TUser> and stamps the stratara:tenant_id claim from the user's tenant membership onto every principal the factory issues — the sign-in bridge between the identity plane and Stratara's session-context middleware, which reads exactly that claim.

public sealed class MembershipClaimsPrincipalFactory<TUser> : IUserClaimsPrincipalFactory<TUser> where TUser : class

Type Parameters

TUser

The host's ASP.NET Identity user entity.

Inheritance
MembershipClaimsPrincipalFactory<TUser>
Implements
Inherited Members
Extension Methods

Remarks

Tenant resolution: the user's persisted active-tenant selection when it points at an active membership, otherwise the user's only — or deterministically first — active membership. A user without any active membership gets no claim, so downstream tenant resolution stays on its fail-closed path. A principal that already carries the claim (a consumer-owned factory stamped it) is left untouched.

The claim is stamped wherever the factory runs — cookie issuance and ASP.NET Identity bearer tokens alike. Principals minted outside the factory (application-owned machine JWTs) stamp the claim themselves.

Constructors

MembershipClaimsPrincipalFactory(IUserClaimsPrincipalFactory<TUser>, ITenantMembershipStore)

Decorates the host's IUserClaimsPrincipalFactory<TUser> and stamps the stratara:tenant_id claim from the user's tenant membership onto every principal the factory issues — the sign-in bridge between the identity plane and Stratara's session-context middleware, which reads exactly that claim.

public MembershipClaimsPrincipalFactory(IUserClaimsPrincipalFactory<TUser> inner, ITenantMembershipStore membershipStore)

Parameters

inner IUserClaimsPrincipalFactory<TUser>

The decorated factory that builds the base principal.

membershipStore ITenantMembershipStore

The membership store the tenant is resolved from.

Remarks

Tenant resolution: the user's persisted active-tenant selection when it points at an active membership, otherwise the user's only — or deterministically first — active membership. A user without any active membership gets no claim, so downstream tenant resolution stays on its fail-closed path. A principal that already carries the claim (a consumer-owned factory stamped it) is left untouched.

The claim is stamped wherever the factory runs — cookie issuance and ASP.NET Identity bearer tokens alike. Principals minted outside the factory (application-owned machine JWTs) stamp the claim themselves.

Methods

CreateAsync(TUser)

Creates a ClaimsPrincipal from an user asynchronously.

public Task<ClaimsPrincipal> CreateAsync(TUser user)

Parameters

user TUser

The user to create a ClaimsPrincipal from.

Returns

Task<ClaimsPrincipal>

The Task that represents the asynchronous creation operation, containing the created ClaimsPrincipal.