Class UmbracoSignInManager<TUser>
Abstract sign in manager implementation allowing modifying all default authentication schemes.
Inheritance
Namespace: Umbraco.Cms.Web.Common.Security
Assembly: Umbraco.Web.Common.dll
Syntax
public abstract class UmbracoSignInManager<TUser> : SignInManager<TUser> where TUser : UmbracoIdentityUser
Type Parameters
| Name | Description |
|---|---|
| TUser |
Constructors
View SourceUmbracoSignInManager(UserManager<TUser>, IHttpContextAccessor, IUserClaimsPrincipalFactory<TUser>, IOptions<IdentityOptions>, ILogger<SignInManager<TUser>>, IAuthenticationSchemeProvider, IUserConfirmation<TUser>, IOptions<SecuritySettings>, IRequestCache)
Declaration
public UmbracoSignInManager(UserManager<TUser> userManager, IHttpContextAccessor contextAccessor, IUserClaimsPrincipalFactory<TUser> claimsFactory, IOptions<IdentityOptions> optionsAccessor, ILogger<SignInManager<TUser>> logger, IAuthenticationSchemeProvider schemes, IUserConfirmation<TUser> confirmation, IOptions<SecuritySettings> securitySettingsOptions, IRequestCache requestCache)
Parameters
| Type | Name | Description |
|---|---|---|
| UserManager<TUser> | userManager | |
| IHttpContextAccessor | contextAccessor | |
| IUserClaimsPrincipalFactory<TUser> | claimsFactory | |
| IOptions<IdentityOptions> | optionsAccessor | |
| ILogger<SignInManager<TUser>> | logger | |
| IAuthenticationSchemeProvider | schemes | |
| IUserConfirmation<TUser> | confirmation | |
| IOptions<SecuritySettings> | securitySettingsOptions | |
| IRequestCache | requestCache |
Fields
View SourceUmbracoSignInMgrLoginProviderKey
Declaration
protected const string UmbracoSignInMgrLoginProviderKey = "LoginProvider"
Field Value
| Type | Description |
|---|---|
| string |
UmbracoSignInMgrXsrfKey
Declaration
protected const string UmbracoSignInMgrXsrfKey = "XsrfId"
Field Value
| Type | Description |
|---|---|
| string |
Properties
View SourceAuthenticationType
Declaration
protected abstract string AuthenticationType { get; }
Property Value
| Type | Description |
|---|---|
| string |
ExternalAuthenticationType
Declaration
protected abstract string ExternalAuthenticationType { get; }
Property Value
| Type | Description |
|---|---|
| string |
TwoFactorAuthenticationType
Declaration
protected abstract string TwoFactorAuthenticationType { get; }
Property Value
| Type | Description |
|---|---|
| string |
TwoFactorRememberMeAuthenticationType
Declaration
protected abstract string TwoFactorRememberMeAuthenticationType { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
View SourceCreateUserPrincipalAsync(Guid)
Declaration
public virtual Task<ClaimsPrincipal?> CreateUserPrincipalAsync(Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userKey |
Returns
| Type | Description |
|---|---|
| Task<ClaimsPrincipal> |
ForgetTwoFactorClientAsync()
Clears the "Remember this browser flag" from the current browser, as an asynchronous operation.
Declaration
public override Task ForgetTwoFactorClientAsync()
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |
GetExternalLoginInfoAsync(string?)
Gets the external login information for the current login, as an asynchronous operation.
Declaration
public override Task<ExternalLoginInfo?> GetExternalLoginInfoAsync(string? expectedXsrf = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | expectedXsrf | Flag indication whether a Cross Site Request Forgery token was expected in the current request. |
Returns
| Type | Description |
|---|---|
| Task<ExternalLoginInfo> | The task object representing the asynchronous operation containing the Microsoft.AspNetCore.Identity.ExternalLoginInfo for the sign-in attempt. |
GetTwoFactorAuthenticationUserAsync()
Gets the TUser for the current two factor authentication login, as an asynchronous operation.
Declaration
public override Task<TUser?> GetTwoFactorAuthenticationUserAsync()
Returns
| Type | Description |
|---|---|
| Task<TUser> | The task object representing the asynchronous operation containing the |
HandleSignIn(TUser?, string?, SignInResult)
Called on any login attempt to update the AccessFailedCount and to raise events
Declaration
protected virtual Task<SignInResult> HandleSignIn(TUser? user, string? username, SignInResult result)
Parameters
| Type | Name | Description |
|---|---|---|
| TUser | user | |
| string | username | |
| SignInResult | result |
Returns
| Type | Description |
|---|---|
| Task<SignInResult> |
IsSignedIn(ClaimsPrincipal)
Returns true if the principal has an identity with the application cookie identity
Declaration
public override bool IsSignedIn(ClaimsPrincipal principal)
Parameters
| Type | Name | Description |
|---|---|---|
| ClaimsPrincipal | principal | The System.Security.Claims.ClaimsPrincipal instance. |
Returns
| Type | Description |
|---|---|
| bool | True if the user is logged in with identity. |
IsTwoFactorClientRememberedAsync(TUser)
Returns a flag indicating if the current client browser has been remembered by two factor authentication for the user attempting to login, as an asynchronous operation.
Declaration
public override Task<bool> IsTwoFactorClientRememberedAsync(TUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| TUser | user | The user attempting to login. |
Returns
| Type | Description |
|---|---|
| Task<bool> | The task object representing the asynchronous operation containing true if the browser has been remembered for the current user. |
PasswordSignInAsync(string, string, bool, bool)
Attempts to sign in the specified userName and password combination
as an asynchronous operation.
Declaration
public override Task<SignInResult> PasswordSignInAsync(string userName, string password, bool isPersistent, bool lockoutOnFailure)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userName | The user name to sign in. |
| string | password | The password to attempt to sign in with. |
| bool | isPersistent | Flag indicating whether the sign-in cookie should persist after the browser is closed. |
| bool | lockoutOnFailure | Flag indicating if the user account should be locked if the sign in fails. |
Returns
| Type | Description |
|---|---|
| Task<SignInResult> | The task object representing the asynchronous operation containing the Microsoft.AspNetCore.Identity.SignInResult for the sign-in attempt. |
PasswordSignInAsync(TUser, string, bool, bool)
Attempts to sign in the specified user and password combination
as an asynchronous operation.
Declaration
public override Task<SignInResult> PasswordSignInAsync(TUser user, string password, bool isPersistent, bool lockoutOnFailure)
Parameters
| Type | Name | Description |
|---|---|---|
| TUser | user | The user to sign in. |
| string | password | The password to attempt to sign in with. |
| bool | isPersistent | Flag indicating whether the sign-in cookie should persist after the browser is closed. |
| bool | lockoutOnFailure | Flag indicating if the user account should be locked if the sign in fails. |
Returns
| Type | Description |
|---|---|
| Task<SignInResult> | The task object representing the asynchronous operation containing the Microsoft.AspNetCore.Identity.SignInResult for the sign-in attempt. |
RefreshSignInAsync(TUser)
Signs in the specified user, whilst preserving the existing
AuthenticationProperties of the current signed-in user like rememberMe, as an asynchronous operation.
Declaration
public override Task RefreshSignInAsync(TUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| TUser | user | The user to sign-in. |
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |
RememberTwoFactorClientAsync(TUser)
Sets a flag on the browser to indicate the user has selected "Remember this browser" for two factor authentication purposes, as an asynchronous operation.
Declaration
public override Task RememberTwoFactorClientAsync(TUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| TUser | user | The user who choose "remember this browser". |
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |
SignInOrTwoFactorAsync(TUser, bool, string?, bool)
Signs in the specified user if bypassTwoFactor is set to false.
Otherwise stores the user for use after a two factor check.
Declaration
protected override Task<SignInResult> SignInOrTwoFactorAsync(TUser user, bool isPersistent, string? loginProvider = null, bool bypassTwoFactor = false)
Parameters
| Type | Name | Description |
|---|---|---|
| TUser | user | |
| bool | isPersistent | Flag indicating whether the sign-in cookie should persist after the browser is closed. |
| string | loginProvider | The login provider to use. Default is null |
| bool | bypassTwoFactor | Flag indicating whether to bypass two factor authentication. Default is false |
Returns
| Type | Description |
|---|---|
| Task<SignInResult> | Returns a Microsoft.AspNetCore.Identity.SignInResult |
SignInWithClaimsAsync(TUser, AuthenticationProperties?, IEnumerable<Claim>)
Signs in the specified user.
Declaration
public override Task SignInWithClaimsAsync(TUser user, AuthenticationProperties? authenticationProperties, IEnumerable<Claim> additionalClaims)
Parameters
| Type | Name | Description |
|---|---|---|
| TUser | user | The user to sign-in. |
| AuthenticationProperties | authenticationProperties | Properties applied to the login and authentication cookie. |
| IEnumerable<Claim> | additionalClaims | Additional claims that will be stored in the cookie. |
Returns
| Type | Description |
|---|---|
| Task | The task object representing the asynchronous operation. |
SignOutAsync()
Signs the current user out of the application.
Declaration
public override Task SignOutAsync()
Returns
| Type | Description |
|---|---|
| Task |
TwoFactorRecoveryCodeSignInAsync(string)
Signs in the user without two factor authentication using a two factor recovery code.
Declaration
public override Task<SignInResult> TwoFactorRecoveryCodeSignInAsync(string recoveryCode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | recoveryCode | The two factor recovery code. |
Returns
| Type | Description |
|---|---|
| Task<SignInResult> |
TwoFactorSignInAsync(string, string, bool, bool)
Validates the two factor sign in code and creates and signs in the user, as an asynchronous operation.
Declaration
public override Task<SignInResult> TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberClient)
Parameters
| Type | Name | Description |
|---|---|---|
| string | provider | The two factor authentication provider to validate the code against. |
| string | code | The two factor authentication code to validate. |
| bool | isPersistent | Flag indicating whether the sign-in cookie should persist after the browser is closed. |
| bool | rememberClient | Flag indicating whether the current browser should be remember, suppressing all further two factor authentication prompts. |
Returns
| Type | Description |
|---|---|
| Task<SignInResult> | The task object representing the asynchronous operation containing the Microsoft.AspNetCore.Identity.SignInResult for the sign-in attempt. |