Class ClaimsIdentityExtensions
Inheritance
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class ClaimsIdentityExtensions
Properties
View SourceRequiredBackOfficeClaimTypes
Returns the required claim types for a back office identity
Declaration
public static IEnumerable<string> RequiredBackOfficeClaimTypes { get; }
Property Value
Type | Description |
---|---|
IEnumerable<System. |
Remarks
This does not include the role claim type or allowed apps type since that is a collection and in theory could be empty
Methods
View SourceAddOrUpdateClaim(ClaimsIdentity, Claim)
Adds or updates and existing claim.
Declaration
public static void AddOrUpdateClaim(this ClaimsIdentity identity, Claim claim)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity | |
System. |
claim |
AddRequiredClaims(ClaimsIdentity, String, Guid, String, String, Nullable<IEnumerable<Int32>>, Nullable<IEnumerable<Int32>>, String, String, IEnumerable<String>, IEnumerable<String>)
Add the required claims to be a BackOffice ClaimsIdentity
Declaration
public static void AddRequiredClaims(this ClaimsIdentity identity, string userId, Guid userKey, string username, string realName, IEnumerable<int>? startContentNodes, IEnumerable<int>? startMediaNodes, string culture, string securityStamp, IEnumerable<string> allowedApps, IEnumerable<string> roles)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity | this |
System. |
userId | The users Id |
Guid | userKey | The users key |
System. |
username | Username |
System. |
realName | Real name |
System. |
startContentNodes | Start content nodes |
System. |
startMediaNodes | Start media nodes |
System. |
culture | The locality of the user |
System. |
securityStamp | Security stamp |
IEnumerable<System. |
allowedApps | Allowed apps |
IEnumerable<System. |
roles | Roles |
FindFirstValue(ClaimsIdentity, String)
Returns the first claim value found in the System.
Declaration
public static string FindFirstValue(this ClaimsIdentity identity, string claimType)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity | |
System. |
claimType |
Returns
Type | Description |
---|---|
System. |
The string value of the claim if found otherwise null |
GetAllowedApplications(ClaimsIdentity)
Get the allowed applications from a ClaimsIdentity
Declaration
public static string[] GetAllowedApplications(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
GetCultureString(ClaimsIdentity)
Get the culture string from a ClaimsIdentity
Declaration
public static string GetCultureString(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
Culture string |
GetEmail(IIdentity)
Declaration
public static string GetEmail(this IIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
GetId(ClaimsIdentity)
Get the user ID from a ClaimsIdentity
Declaration
public static int? GetId(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
User ID as integer |
GetRealName(ClaimsIdentity)
Get the real name belonging to the user from a ClaimsIdentity
Declaration
public static string GetRealName(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
Real name of the user |
GetRoles(ClaimsIdentity)
Get the roles assigned to a user from a ClaimsIdentity
Declaration
public static string[] GetRoles(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
Array of roles |
GetSecurityStamp(ClaimsIdentity)
Get the security stamp from a ClaimsIdentity
Declaration
public static string GetSecurityStamp(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
Security stamp |
GetStartContentNodes(ClaimsIdentity)
Get the start content nodes from a ClaimsIdentity
Declaration
public static int[] GetStartContentNodes(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
Array of start content nodes |
GetStartMediaNodes(ClaimsIdentity)
Get the start media nodes from a ClaimsIdentity
Declaration
public static int[] GetStartMediaNodes(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
Array of start media nodes |
GetUserId(IIdentity)
Returns the user id from the System.
Declaration
public static string GetUserId(this IIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
The string value of the user id if found otherwise null |
GetUserId<T>(IIdentity)
Declaration
public static T GetUserId<T>(this IIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
GetUserKey(IIdentity)
Returns the user key from the System.
Declaration
public static Guid? GetUserKey(this IIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
The string value of the user id if found otherwise null. |
GetUsername(ClaimsIdentity)
Get the username of the user from a ClaimsIdentity
Declaration
public static string GetUsername(this ClaimsIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
Username of the user |
GetUserName(IIdentity)
Returns the user name from the System.
Declaration
public static string GetUserName(this IIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity |
Returns
Type | Description |
---|---|
System. |
The string value of the user name if found otherwise null |
VerifyBackOfficeIdentity(ClaimsIdentity, out ClaimsIdentity)
Verify that a ClaimsIdentity has all the required claim types
Declaration
public static bool VerifyBackOfficeIdentity(this ClaimsIdentity identity, out ClaimsIdentity verifiedIdentity)
Parameters
Type | Name | Description |
---|---|---|
System. |
identity | |
System. |
verifiedIdentity | Verified identity wrapped in a ClaimsIdentity with BackOfficeAuthentication type |
Returns
Type | Description |
---|---|
System. |
True if ClaimsIdentity |