// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Identity { /// /// Responsible for validation of two factor identity cookie security stamp. /// /// The type encapsulating a user. public class TwoFactorSecurityStampValidator : SecurityStampValidator, ITwoFactorSecurityStampValidator where TUser : class { /// /// Creates a new instance of . /// /// Used to access the . /// The . /// The system clock. public TwoFactorSecurityStampValidator(IOptions options, SignInManager signInManager, ISystemClock clock) : base(options, signInManager, clock) { } /// /// Verifies the principal's security stamp, returns the matching user if successful /// /// The principal to verify. /// The verified user or null if verification fails. protected override Task VerifySecurityStamp(ClaimsPrincipal principal) => SignInManager.ValidateTwoFactorSecurityStampAsync(principal); /// /// Called when the security stamp has been verified. /// /// The user who has been verified. /// The . /// A task. protected override Task SecurityStampVerified(TUser user, CookieValidatePrincipalContext context) => Task.CompletedTask; } }