Skip to main content
Version: 4.2

OAuthPrincipal

Namespace: Wisej.Web

Assembly: Wisej.Framework (4.2.0.0)

The principal assigned to User after a successful sign-in.

4.2.0+
public class OAuthPrincipal : ClaimsPrincipal

Constructors​

Instance member OAuthPrincipal(identity)​

Initializes a new instance of the OAuthPrincipal class.

NameTypeDescription
identityOAuthIdentityThe signed-in identity.

Instance member OAuthPrincipal(identity, roles)​

Initializes a new instance of the OAuthPrincipal class and adds the specified roles as claims of the identity's role claim type.

NameTypeDescription
identityOAuthIdentityThe signed-in identity.
rolesIEnumerable<String>The role names to add. Null is allowed and adds nothing.

Each role becomes a claim of the identity's own RoleClaimType - always "roles", which CreateIdentity fixes - and not of a hard-coded claim type, so the inherited IsInRole finds them. This constructor is how an Authenticating handler adds roles from another source - Entra groups, for instance - while keeping this principal and its OAuthIdentity on User. A null or empty entry is skipped: a claim with no value is not a role.

Properties​

Instance member Identity​

OAuthIdentity: Returns the signed-in OAuthIdentity.

Instance member Provider​

OAuthProvider: Returns the provider that authenticated this user.