Class UserIdentityResolver
- Namespace
- Tharga.Team
- Assembly
- Tharga.Team.dll
The one place a principal is turned into the identity a user is stored and audited under.
public sealed class UserIdentityResolver
- Inheritance
-
UserIdentityResolver
- Inherited Members
Remarks
Unconfigured, every caller keeps exactly the behaviour it had before this type existed. The user
record is found by Tharga.Toolkit's GetIdentity() chain, and the audit subject is
NameIdentifier alone.
Configured, both answers come from the listed claim types, in order, and nothing else. There is no
fallback to the default chain: a principal without any listed claim resolves to null rather than
to a second identity for the same person. List more than one type to allow an explicit fallback.
Why it exists. In Microsoft Entra (workforce and External ID) sub is pairwise — unique per
user and application — and OIDC inbound claim mapping copies it into
NameIdentifier, which the default chain reads first. Replacing an app
registration therefore re-keys every user, and two applications in one tenant can never share user
records. oid is the tenant-wide object id; configure ObjectId.
ObjectId and ObjectIdentifier are treated as one claim, so listing either works whether or not inbound claim mapping is on.
Constructors
UserIdentityResolver()
Creates the unconfigured resolver.
public UserIdentityResolver()
UserIdentityResolver(IEnumerable<string>)
Creates a resolver reading the given claim types in order; null or empty means unconfigured.
public UserIdentityResolver(IEnumerable<string> claimTypes)
Parameters
claimTypesIEnumerable<string>
Exceptions
- ArgumentException
A listed claim type is null or whitespace.
Properties
ClaimTypes
The configured claim types, in order. Empty when unconfigured.
public IReadOnlyList<string> ClaimTypes { get; }
Property Value
Default
The unconfigured resolver: today's behaviour at every call site.
public static UserIdentityResolver Default { get; }
Property Value
IsConfigured
True when claim types were configured, replacing the default resolution everywhere.
public bool IsConfigured { get; }
Property Value
Methods
GetSubject(ClaimsPrincipal)
The exact-matchable subject recorded on audit entries and support cases, or null when the principal carries none.
public string GetSubject(ClaimsPrincipal principal)
Parameters
principalClaimsPrincipal
Returns
GetUserIdentity(ClaimsPrincipal)
The identity the user record is stored under (Identity), or null when the principal carries none.
public string GetUserIdentity(ClaimsPrincipal principal)
Parameters
principalClaimsPrincipal