Class IdentityHelperExtensions
Class IdentityHelper.
Inherited Members
Namespace: FastMoq.Extensions
Assembly: FastMoq.Core.dll
Syntax
public static class IdentityHelperExtensions
Methods
CreateClaim(string, string, Dictionary<string, string>?, bool)
Creates a claim.
Declaration
public static Claim CreateClaim(string type, string value, Dictionary<string, string>? properties = null, bool allowCustomType = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type of claim. Must be from ClaimTypes. |
| string | value | Value of the claim. |
| Dictionary<string, string> | properties | Claim Properties. |
| bool | allowCustomType | Indicates if type is validated. If custom type is allowed, then the type string is not validated. |
Returns
| Type | Description |
|---|---|
| Claim |
CreatePrincipal(IEnumerable<Claim>, string?)
Creates the principal.
Declaration
public static ClaimsPrincipal CreatePrincipal(IEnumerable<Claim> claims, string? authenticationType = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Claim> | claims | The claims. |
| string | authenticationType | Type of the authentication. |
Returns
| Type | Description |
|---|---|
| ClaimsPrincipal | ClaimsPrincipal. |
IsValidClaimType(string)
Determines whether given type is included as a ClaimTypes constant. Custom types may be valid, but this method will return false.
Declaration
public static bool IsValidClaimType(string type)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type. |
Returns
| Type | Description |
|---|---|
| bool |
|
SetUser(HttpContext, ClaimsIdentity)
Sets the user.
Declaration
public static void SetUser(this HttpContext context, ClaimsIdentity identity)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpContext | context | The context. |
| ClaimsIdentity | identity | The principal. |
SetUser(HttpContext, ClaimsPrincipal)
Sets the user.
Declaration
public static void SetUser(this HttpContext context, ClaimsPrincipal principal)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpContext | context | The context. |
| ClaimsPrincipal | principal | The principal. |