public async Task <IActionResult> OnGetAsync(bool rememberMe, string returnUrl = null) { ReturnUrl = returnUrl ?? "/"; RememberMe = rememberMe; // Ensure the user has gone through the username & password screen first var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); if (user is null) { throw new InvalidOperationException($"Unable to load two-factor authentication user."); } /* * var credentials = (await _store.GetCredentialIdsForUser(user.Email)).ToList(); * if (!credentials.Any()) * throw new PublicKeyCredentialException("No keys registered for user"); */ // Creates the required fields for the `publicKeyCredentialRequestOptions` which are: // Base64Challenge, RelyingPartyId, UserId & Base64KeyIds if any AuthChallenge = await _fido.InitiateAuthentication(user.Email); // model.UserId return(Page()); }
public async Task <IActionResult> FidoLogin() { var result = await HttpContext.AuthenticateAsync(IdentityConstants.TwoFactorUserIdScheme); if (result.Succeeded) { var claims = result.Principal.Claims.ToList(); string userName = claims.FirstOrDefault(c => c.Type == "userName")?.Value; string redirectUrl = claims.FirstOrDefault(c => c.Type == "redirectUrl")?.Value; var challenge = await _fido.InitiateAuthentication(userName); var nonce = GeneratorNonce(); var model = new FidoIdSModel() { Challenge = challenge.ToBase64Dto(), ReturnUrl = redirectUrl, Nonce = nonce }; return(View(model)); } return(new RedirectResult("/Home/Error")); }
public async Task <IActionResult> FidoLogin() { var challenge = await fido.InitiateAuthentication(null, new FidoAuthenticationRequestOptions { RequireUserPresent = true, RequireUserVerification = true }); return(View(challenge.ToBase64Dto())); }
public async Task <IActionResult> OnGetAsync(bool rememberMe, string returnUrl = null) { ReturnUrl = returnUrl ?? "/"; RememberMe = rememberMe; // Creates the required fields for the `publicKeyCredentialRequestOptions` which are: // Base64Challenge, RelyingPartyId, UserId & Base64KeyIds if any AuthChallenge = (await _fido.InitiateAuthentication(null)).ToBase64Dto(); // since the user credential is stored in the key return(Page()); }
public async Task <IActionResult> FidoLogin() { var authResult = await HttpContext.AuthenticateAsync(IdentityConstants.TwoFactorUserIdScheme); if (!authResult.Succeeded) { return(Unauthorized()); } var challenge = await fido.InitiateAuthentication(authResult.Principal.FindFirstValue("userId")); return(View(challenge.ToBase64Dto())); }
public async Task <IActionResult> Login() { var result = await HttpContext.AuthenticateAsync(IdentityConstants.TwoFactorUserIdScheme); if (result.Succeeded) { var claims = result.Principal.Claims.ToList(); string userName = claims.FirstOrDefault(c => c.Type == "userName")?.Value; var challenge = await _fido.InitiateAuthentication(userName); return(View(challenge.ToBase64Dto())); } return(new RedirectResult("/Home/Error")); }
public async Task <IActionResult> Login() { var challenge = await fido.InitiateAuthentication(null); return(View(challenge)); }
public async Task <IActionResult> Login(LoginModel model) { var challenge = await fido.InitiateAuthentication(model.UserId); return(View(challenge.ToBase64Dto())); }