• Core
  • Infrastructure
  • Web
  • Extensions
Search Results for

    Show / Hide Table of Contents
    View Source

    Class ClaimsIdentityExtensions

    Inheritance
    System.Object
    Namespace: Umbraco.Extensions
    Assembly: Umbraco.Core.dll
    Syntax
    public static class ClaimsIdentityExtensions

    Properties

    View Source

    RequiredBackOfficeClaimTypes

    Returns the required claim types for a back office identity

    Declaration
    public static IEnumerable<string> RequiredBackOfficeClaimTypes { get; }
    Property Value
    Type Description
    IEnumerable<System.String>
    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 Source

    AddOrUpdateClaim(ClaimsIdentity, Claim)

    Adds or updates and existing claim.

    Declaration
    public static void AddOrUpdateClaim(this ClaimsIdentity identity, Claim claim)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    System.Security.Claims.Claim claim
    View Source

    AddRequiredClaims(ClaimsIdentity, String, 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, 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.Security.Claims.ClaimsIdentity identity

    this

    System.String userId

    The users Id

    System.String username

    Username

    System.String realName

    Real name

    System.Nullable<IEnumerable<System.Int32>> startContentNodes

    Start content nodes

    System.Nullable<IEnumerable<System.Int32>> startMediaNodes

    Start media nodes

    System.String culture

    The locality of the user

    System.String securityStamp

    Security stamp

    IEnumerable<System.String> allowedApps

    Allowed apps

    IEnumerable<System.String> roles

    Roles

    View Source

    FindFirstValue(ClaimsIdentity, String)

    Returns the first claim value found in the System.Security.Claims.ClaimsIdentity for the given claimType

    Declaration
    public static string FindFirstValue(this ClaimsIdentity identity, string claimType)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    System.String claimType
    Returns
    Type Description
    System.String

    The string value of the claim if found otherwise null

    View Source

    GetAllowedApplications(ClaimsIdentity)

    Get the allowed applications from a ClaimsIdentity

    Declaration
    public static string[] GetAllowedApplications(this ClaimsIdentity identity)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.String[]
    View Source

    GetCultureString(ClaimsIdentity)

    Get the culture string from a ClaimsIdentity

    Declaration
    public static string GetCultureString(this ClaimsIdentity identity)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.String

    Culture string

    View Source

    GetEmail(IIdentity)

    Declaration
    public static string GetEmail(this IIdentity identity)
    Parameters
    Type Name Description
    System.Security.Principal.IIdentity identity
    Returns
    Type Description
    System.String
    View Source

    GetId(ClaimsIdentity)

    Get the user ID from a ClaimsIdentity

    Declaration
    public static int? GetId(this ClaimsIdentity identity)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.Nullable<System.Int32>

    User ID as integer

    View Source

    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.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.String

    Real name of the user

    View Source

    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.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.String[]

    Array of roles

    View Source

    GetSecurityStamp(ClaimsIdentity)

    Get the security stamp from a ClaimsIdentity

    Declaration
    public static string GetSecurityStamp(this ClaimsIdentity identity)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.String

    Security stamp

    View Source

    GetStartContentNodes(ClaimsIdentity)

    Get the start content nodes from a ClaimsIdentity

    Declaration
    public static int[] GetStartContentNodes(this ClaimsIdentity identity)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.Int32[]

    Array of start content nodes

    View Source

    GetStartMediaNodes(ClaimsIdentity)

    Get the start media nodes from a ClaimsIdentity

    Declaration
    public static int[] GetStartMediaNodes(this ClaimsIdentity identity)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.Int32[]

    Array of start media nodes

    View Source

    GetUserId(IIdentity)

    Returns the user id from the System.Security.Principal.IIdentity of either the claim type System.Security.Claims.ClaimTypes.NameIdentifier or "sub"

    Declaration
    public static string GetUserId(this IIdentity identity)
    Parameters
    Type Name Description
    System.Security.Principal.IIdentity identity
    Returns
    Type Description
    System.String

    The string value of the user id if found otherwise null

    View Source

    GetUserId<T>(IIdentity)

    Declaration
    public static T GetUserId<T>(this IIdentity identity)
    Parameters
    Type Name Description
    System.Security.Principal.IIdentity identity
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    View Source

    GetUsername(ClaimsIdentity)

    Get the username of the user from a ClaimsIdentity

    Declaration
    public static string GetUsername(this ClaimsIdentity identity)
    Parameters
    Type Name Description
    System.Security.Claims.ClaimsIdentity identity
    Returns
    Type Description
    System.String

    Username of the user

    View Source

    GetUserName(IIdentity)

    Returns the user name from the System.Security.Principal.IIdentity of either the claim type System.Security.Claims.ClaimTypes.Name or "preferred_username"

    Declaration
    public static string GetUserName(this IIdentity identity)
    Parameters
    Type Name Description
    System.Security.Principal.IIdentity identity
    Returns
    Type Description
    System.String

    The string value of the user name if found otherwise null

    View Source

    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.Security.Claims.ClaimsIdentity identity
    System.Security.Claims.ClaimsIdentity verifiedIdentity

    Verified identity wrapped in a ClaimsIdentity with BackOfficeAuthentication type

    Returns
    Type Description
    System.Boolean

    True if ClaimsIdentity

    • Improve this Doc
    • View Source
    In This Article
    • Properties
      • RequiredBackOfficeClaimTypes
    • Methods
      • AddOrUpdateClaim(ClaimsIdentity, Claim)
      • AddRequiredClaims(ClaimsIdentity, String, String, String, Nullable<IEnumerable<Int32>>, Nullable<IEnumerable<Int32>>, String, String, IEnumerable<String>, IEnumerable<String>)
      • FindFirstValue(ClaimsIdentity, String)
      • GetAllowedApplications(ClaimsIdentity)
      • GetCultureString(ClaimsIdentity)
      • GetEmail(IIdentity)
      • GetId(ClaimsIdentity)
      • GetRealName(ClaimsIdentity)
      • GetRoles(ClaimsIdentity)
      • GetSecurityStamp(ClaimsIdentity)
      • GetStartContentNodes(ClaimsIdentity)
      • GetStartMediaNodes(ClaimsIdentity)
      • GetUserId(IIdentity)
      • GetUserId<T>(IIdentity)
      • GetUsername(ClaimsIdentity)
      • GetUserName(IIdentity)
      • VerifyBackOfficeIdentity(ClaimsIdentity, out ClaimsIdentity)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX