Skip to main content

Definition

Assembly: System.Security.Claims.dll Namespace: System.Security.Claims

Syntax

Summary

This type is defined in System.Security.Claims.

Remarks

See Microsoft documentation for more information about the rest of the API.

Methods

GetUserEmail Extension

Extension method from System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensions
Gets the user email from the claims principal.

Syntax

Parameters

Returns

Type: string? The user email, or null if not found.

Remarks

This method looks for the email in common claim types used by different authentication providers.

GetUserId Extension

Extension method from System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensions
Gets the user identifier from the claims principal.

Syntax

Parameters

Returns

Type: string? The user identifier, or null if not found.

Remarks

This method looks for the user identifier in common claim types used by different authentication providers.

GetUserName Extension

Extension method from System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensions
Gets the username from the claims principal.

Syntax

Parameters

Returns

Type: string? The username, or null if not found.

Remarks

This method looks for the username in common claim types used by different authentication providers.

GetUserRoles Extension

Extension method from System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensions
Gets the user roles from the claims principal.

Syntax

Parameters

Returns

Type: System.Collections.Generic.IEnumerable<string> A collection of user roles, or empty if no roles are found.

Examples

Remarks

This method looks for roles in various claim types commonly used by different authentication providers. Roles can be in individual claims or comma-separated values.

GetUserScopes Extension

Extension method from System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensions
Gets the user scopes from the claims principal.

Syntax

Parameters

Returns

Type: System.Collections.Generic.IEnumerable<string> A collection of user scopes, or empty if no scopes are found.

Examples

Remarks

This method looks for scopes in various claim types commonly used by different authentication providers. Scopes are typically space-separated values in a single claim.

HasRole Extension

Extension method from System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensions
Determines whether the user has the specified role.

Syntax

Parameters

Returns

Type: bool true if the user has the specified role; otherwise, false.

HasScope Extension

Extension method from System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensions
Determines whether the user has the specified scope.

Syntax

Parameters

Returns

Type: bool true if the user has the specified scope; otherwise, false.