[{"data":1,"prerenderedAt":6432},["ShallowReactive",2],{"\u002Fblog\u002Frails-passwordless-authentication-webauthn-2fa":3},{"path":4,"data":5,"meta":18,"nodes":88},"\u002Fblog\u002Frails-passwordless-authentication-webauthn-2fa",{"title":6,"description":7,"date":8,"tags":9,"authors":11,"image":14,"seo":15},"WebAuthn Authentication: From 2FA to Password-less","Master password-less authentication in Rails","2026-02-18",[10],"engineering",[12,13],"Ali Fadel","Ibraheem Tuffaha","\u002Fimages\u002Fblog\u002Frails-passwordless-authentication-webauthn-2fa.webp",{"title":16,"description":17},"WebAuthn in Rails: 2FA and Password-less Authentication","Master password-less authentication in Rails. Transition from traditional 2FA to a secure passkey-only sign-in flow for better UX and security",{"toc":19,"key":80,"source":81,"stem":82,"extension":83,"kind":84,"type":85,"partial":86,"hash":87},{"title":20,"searchDepth":21,"depth":21,"links":22},"",2,[23,52,67,74,77],{"id":24,"depth":21,"text":25,"children":26},"password-full-authentication-2fa-with-passkeys","Password-Full Authentication (2FA with Passkeys)",[27,31,34,37,40,43,46,49],{"id":28,"depth":29,"text":30},"password-full-authentication-2fa-with-passkeys-the-authentication-concern-backend",3,"The Authentication Concern [Backend]",{"id":32,"depth":29,"text":33},"password-full-authentication-2fa-with-passkeys-the-pendingauthentication-concern-backend","The PendingAuthentication Concern [Backend]",{"id":35,"depth":29,"text":36},"password-full-authentication-2fa-with-passkeys-the-routes-backend","The Routes [Backend]",{"id":38,"depth":29,"text":39},"password-full-authentication-2fa-with-passkeys-modifying-devises-sessions-controller-backend","Modifying Devise's Sessions Controller [Backend]",{"id":41,"depth":29,"text":42},"password-full-authentication-2fa-with-passkeys-the-challenge-controller-backend","The Challenge Controller [Backend]",{"id":44,"depth":29,"text":45},"password-full-authentication-2fa-with-passkeys-the-authentication-controller-backend","The Authentication Controller [Backend]",{"id":47,"depth":29,"text":48},"password-full-authentication-2fa-with-passkeys-the-two-factor-auth-page-frontend","The Two-Factor Auth Page [Frontend]",{"id":50,"depth":29,"text":51},"password-full-authentication-2fa-with-passkeys-what-can-go-wrong","What Can Go Wrong",{"id":53,"depth":21,"text":54,"children":55},"password-less-authentication","Password-Less Authentication",[56,59,62,65],{"id":57,"depth":29,"text":58},"password-less-authentication-the-lookup-controller-backend","The Lookup Controller [Backend]",{"id":60,"depth":29,"text":61},"password-less-authentication-the-sessions-controller-password-less-path-backend","The Sessions Controller (Password-Less Path) [Backend]",{"id":63,"depth":29,"text":64},"password-less-authentication-adaptive-sign-in-flow-frontend","Adaptive Sign-In Flow [Frontend]",{"id":66,"depth":29,"text":51},"password-less-authentication-what-can-go-wrong",{"id":68,"depth":21,"text":69,"children":70},"cleaning-up-removing-password-full-infrastructure","Cleaning Up: Removing Password-Full Infrastructure",[71],{"id":72,"depth":29,"text":73},"cleaning-up-removing-password-full-infrastructure-strengthening-webauthn-options-for-password-less","Strengthening WebAuthn Options for Password-Less",{"id":75,"depth":21,"text":76},"routes-added-in-this-part","Routes Added in This Part",{"id":78,"depth":21,"text":79},"whats-next","What's Next","blog\u002Frails-passwordless-authentication-webauthn-2fa.md","blog","rails-passwordless-authentication-webauthn-2fa",".md","document","text\u002Fmarkdown",false,"95db508fb6651efe",[89,96,164,171,174,180,186,189,192,198,201,204,376,379,418,425,428,434,607,610,612,615,879,882,892,902,912,914,917,993,996,1018,1021,1023,1026,1409,1412,1418,1435,1440,1450,1482,1485,1568,1571,1577,1579,1582,1824,1838,1840,1843,2408,2411,2422,2427,2432,2467,2473,2488,2491,2512,2515,2517,2524,2795,2798,2801,3299,3302,3305,3882,3885,3891,3893,3896,3919,3921,3924,3929,3931,3934,3968,3971,4110,4116,4128,4130,4133,4171,4331,4341,4347,4349,4352,4757,4760,5120,5123,5128,5131,5192,5199,5202,5429,5432,5858,5860,5863,5880,5882,5885,5890,5936,5942,5952,5986,5998,6011,6013,6023,6026,6153,6156,6214,6224,6238,6244,6258,6260,6358,6361,6390,6392,6395,6406,6412,6422],[90,91,92],"p",{},[93,94,95],"em",{},"This is Part 2 of a 4-part series on implementing WebAuthn in Rails with Devise and Inertia.js.",[97,98,99,112],"table",{},[100,101,102],"thead",{},[103,104,105,109],"tr",{},[106,107,108],"th",{},"Part",[106,110,111],{},"Title",[113,114,115,128,142,153],"tbody",{},[103,116,117,121],{},[118,119,120],"td",{},"1",[118,122,123],{},[124,125,127],"a",{"href":126},"https:\u002F\u002Fwww.milkstraw.ai\u002Fblog\u002Fwebauthn-rails-setup-passkey-registration","Setup and Registration",[103,129,130,136],{},[118,131,132],{},[133,134,135],"strong",{},"2",[118,137,138,141],{},[133,139,140],{},"Authentication: From 2FA to Password-less"," (you are here)",[103,143,144,147],{},[118,145,146],{},"3",[118,148,149],{},[124,150,152],{"href":151},"https:\u002F\u002Fwww.milkstraw.ai\u002Fblog\u002Fwebauthn-backup-codes-account-recovery-rails","Backup Codes: The Safety Net",[103,154,155,158],{},[118,156,157],{},"4",[118,159,160],{},[124,161,163],{"href":162},"https:\u002F\u002Fwww.milkstraw.ai\u002Fblog\u002Fwebauthn-implementation-design-tradeoffs-rails","Design Decisions and Trade-offs",[90,165,166,167,170],{},"In ",[124,168,169],{"href":126},"Part 1",", we set up the WebAuthn gem, created the database schema, and built passkey registration. Users can now add passkeys to their accounts.",[90,172,173],{},"In this post, we'll implement the full Rails authentication flow. We'll start with password-full WebAuthn 2FA (password + passkey), then add password-less authentication (passkey only) for a truly secure sign-in experience. Finally, we'll clean up the code to settle on the simpler password-less solution.",[90,175,176,179],{},[133,177,178],{},"Why build 2FA first?"," We want to cover both common use cases. Implementing the password-full flow first ensures we understand the fundamentals of WebAuthn authentication before refactoring to the simpler password-less solution.",[90,181,182,185],{},[133,183,184],{},"Note",": If you only want password-less authentication, you can still read the 2FA sections for context on how the authentication flow works, but focus on the password-less and \"Cleaning Up\" sections for your actual implementation.",[187,188,25],"h2",{"id":24},[90,190,191],{},"Now that users can register passkeys, we need to verify them during sign-in. In this password-full flow, users first enter their password, then complete 2FA with their passkey.",[90,193,194],{},[195,196],"img",{"src":197},"\u002Fimages\u002Fblog\u002Frails-passwordless-authentication-webauthn-2fa-1.webp",[199,200,30],"h3",{"id":28},[90,202,203],{},"The Authentication concern handles two things: ensuring users are signed in, and enforcing WebAuthn 2FA for users who have it enabled:",[205,206,209],"pre",{"language":207,"class":208},"ruby","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[210,211,213,222,223,222,233,222,249,222,251,222,259,222,267,222,274,222,279,222,281,222,286,222,288,222,293,222,302,222,307,222,335,222,337,222,360,222,362,222,367,222,371],"code",{"class":212},"language-ruby",[214,215,218],"span",{"class":216,"style":217},"line","display: inline",[214,219,221],{"style":220},"color:#6E7781;--shiki-dark:#8B949E","# app\u002Fcontrollers\u002Fconcerns\u002Fauthentication.rb","\n",[214,224,225,229],{"class":216,"style":217},[214,226,228],{"style":227},"color:#CF222E;--shiki-dark:#FF7B72","module",[214,230,232],{"style":231},"color:#953800;--shiki-dark:#FFA657"," Authentication",[214,234,235,238,242,246],{"class":216,"style":217},[214,236,237],{"style":227},"  extend",[214,239,241],{"style":240},"color:#0550AE;--shiki-dark:#79C0FF"," ActiveSupport",[214,243,245],{"style":244},"color:#1F2328;--shiki-dark:#E6EDF3","::",[214,247,248],{"style":240},"Concern",[214,250],{"class":216,"style":217},[214,252,253,256],{"class":216,"style":217},[214,254,255],{"style":244},"  included ",[214,257,258],{"style":227},"do",[214,260,261,264],{"class":216,"style":217},[214,262,263],{"style":244},"    before_action ",[214,265,266],{"style":240},":authenticate_user!",[214,268,269,271],{"class":216,"style":217},[214,270,263],{"style":244},[214,272,273],{"style":240},":enforce_web_authn_verification",[214,275,276],{"class":216,"style":217},[214,277,278],{"style":227},"  end",[214,280],{"class":216,"style":217},[214,282,283],{"class":216,"style":217},[214,284,285],{"style":227},"  private",[214,287],{"class":216,"style":217},[214,289,290],{"class":216,"style":217},[214,291,292],{"style":220},"  # Prevent access to protected routes if WebAuthn 2FA is pending.",[214,294,295,298],{"class":216,"style":217},[214,296,297],{"style":227},"  def",[214,299,301],{"style":300},"color:#8250DF;--shiki-dark:#D2A8FF"," enforce_web_authn_verification",[214,303,304],{"class":216,"style":217},[214,305,306],{"style":220},"    # If user is already signed in, they've completed authentication -> Clear stale WebAuthn session if it exists.",[214,308,309,312,315,318,321,323,326,329,332],{"class":216,"style":217},[214,310,311],{"style":244},"    session.",[214,313,314],{"style":300},"delete",[214,316,317],{"style":244},"(",[214,319,320],{"style":240},"WebAuthn",[214,322,245],{"style":244},[214,324,325],{"style":240},"SESSION_KEY",[214,327,328],{"style":244},") ",[214,330,331],{"style":227},"if",[214,333,334],{"style":244}," user_signed_in?",[214,336],{"class":216,"style":217},[214,338,339,342,345,348,350,352,354,357],{"class":216,"style":217},[214,340,341],{"style":227},"    return",[214,343,344],{"style":227}," if",[214,346,347],{"style":244}," session[",[214,349,320],{"style":240},[214,351,245],{"style":244},[214,353,325],{"style":240},[214,355,356],{"style":244},"].",[214,358,359],{"style":300},"blank?",[214,361],{"class":216,"style":217},[214,363,364],{"class":216,"style":217},[214,365,366],{"style":244},"    redirect_to new_web_authn_authentication_path",[214,368,369],{"class":216,"style":217},[214,370,278],{"style":227},[214,372,373],{"class":216,"style":217},[214,374,375],{"style":227},"end",[90,377,378],{},"Include it in your ApplicationController:",[205,380,381],{"language":207,"class":208},[210,382,383,222,388,222,402,222,409,222,414],{"class":212},[214,384,385],{"class":216,"style":217},[214,386,387],{"style":220},"# app\u002Fcontrollers\u002Fapplication_controller.rb",[214,389,390,393,396,399],{"class":216,"style":217},[214,391,392],{"style":227},"class",[214,394,395],{"style":231}," ApplicationController",[214,397,398],{"style":244}," \u003C ",[214,400,401],{"style":240},"ActionController::Base",[214,403,404,407],{"class":216,"style":217},[214,405,406],{"style":227},"  include",[214,408,232],{"style":240},[214,410,411],{"class":216,"style":217},[214,412,413],{"style":220},"  # ...",[214,415,416],{"class":216,"style":217},[214,417,375],{"style":227},[90,419,420,421,424],{},"The ",[210,422,423],{},"enforce_web_authn_verification"," method is the key to password-full 2FA. After a user signs in with their password, if they have WebAuthn enabled, they get redirected to the 2FA page. This method intercepts requests and ensures they complete 2FA before accessing protected routes.",[90,426,427],{},"It also handles edge cases: if a different user abandoned their 2FA attempt and someone else signed in, we clear the stale session.",[90,429,430,433],{},[133,431,432],{},"Important",": You need to skip this callback in controllers that handle public requests or the 2FA flow itself. Otherwise users would be stuck in a redirect loop:",[205,435,436],{"language":207,"class":208},[210,437,438,222,443,222,455,222,471,222,475,222,477,222,489,222,502,222,506,222,508,222,520,222,526,222,530,222,532,222,544,222,550,222,554,222,556,222,568,222,574,222,578,222,580,222,585,222,597,222,603],{"class":212},[214,439,440],{"class":216,"style":217},[214,441,442],{"style":220},"# Devise controllers that handle unauthenticated requests",[214,444,445,447,450,452],{"class":216,"style":217},[214,446,392],{"style":227},[214,448,449],{"style":231}," Users::SessionsController",[214,451,398],{"style":244},[214,453,454],{"style":240},"Devise::SessionsController",[214,456,457,460,462,465,468],{"class":216,"style":217},[214,458,459],{"style":244},"  skip_before_action ",[214,461,273],{"style":240},[214,463,464],{"style":244},", ",[214,466,467],{"style":240},"only:",[214,469,470],{"style":240}," %i[new create destroy]",[214,472,473],{"class":216,"style":217},[214,474,375],{"style":227},[214,476],{"class":216,"style":217},[214,478,479,481,484,486],{"class":216,"style":217},[214,480,392],{"style":227},[214,482,483],{"style":231}," Users::RegistrationsController",[214,485,398],{"style":244},[214,487,488],{"style":240},"Devise::RegistrationsController",[214,490,491,493,495,497,499],{"class":216,"style":217},[214,492,459],{"style":244},[214,494,273],{"style":240},[214,496,464],{"style":244},[214,498,467],{"style":240},[214,500,501],{"style":240}," %i[new create]",[214,503,504],{"class":216,"style":217},[214,505,375],{"style":227},[214,507],{"class":216,"style":217},[214,509,510,512,515,517],{"class":216,"style":217},[214,511,392],{"style":227},[214,513,514],{"style":231}," Users::PasswordsController",[214,516,398],{"style":244},[214,518,519],{"style":240},"Devise::PasswordsController",[214,521,522,524],{"class":216,"style":217},[214,523,459],{"style":244},[214,525,273],{"style":240},[214,527,528],{"class":216,"style":217},[214,529,375],{"style":227},[214,531],{"class":216,"style":217},[214,533,534,536,539,541],{"class":216,"style":217},[214,535,392],{"style":227},[214,537,538],{"style":231}," Users::ConfirmationsController",[214,540,398],{"style":244},[214,542,543],{"style":240},"Devise::ConfirmationsController",[214,545,546,548],{"class":216,"style":217},[214,547,459],{"style":244},[214,549,273],{"style":240},[214,551,552],{"class":216,"style":217},[214,553,375],{"style":227},[214,555],{"class":216,"style":217},[214,557,558,560,563,565],{"class":216,"style":217},[214,559,392],{"style":227},[214,561,562],{"style":231}," Users::UnlocksController",[214,564,398],{"style":244},[214,566,567],{"style":240},"Devise::UnlocksController",[214,569,570,572],{"class":216,"style":217},[214,571,459],{"style":244},[214,573,273],{"style":240},[214,575,576],{"class":216,"style":217},[214,577,375],{"style":227},[214,579],{"class":216,"style":217},[214,581,582],{"class":216,"style":217},[214,583,584],{"style":220},"# The 2FA controller itself (we'll create this next)",[214,586,587,589,592,594],{"class":216,"style":217},[214,588,392],{"style":227},[214,590,591],{"style":231}," WebAuthn::AuthenticationsController",[214,593,398],{"style":244},[214,595,596],{"style":240},"ApplicationController",[214,598,599,601],{"class":216,"style":217},[214,600,459],{"style":244},[214,602,273],{"style":240},[214,604,605],{"class":216,"style":217},[214,606,375],{"style":227},[90,608,609],{},"The pattern is simple: any controller action that a user might hit before completing 2FA needs the skip.",[199,611,33],{"id":32},[90,613,614],{},"We also need a concern for controllers that handle the 2FA flow. These controllers work with users who haven't fully signed in yet. They need to retrieve the pending user from the session, complete the sign-in when verification succeeds, and clean up the session appropriately:",[205,616,617],{"language":207,"class":208},[210,618,619,222,624,222,631,222,641,222,643,222,649,222,656,222,660,222,662,222,666,222,668,222,675,222,694,222,696,222,708,222,712,222,714,222,721,222,759,222,763,222,765,222,775,222,803,222,819,222,821,222,841,222,843,222,859,222,861,222,871,222,875],{"class":212},[214,620,621],{"class":216,"style":217},[214,622,623],{"style":220},"# app\u002Fcontrollers\u002Fconcerns\u002Fpending_authentication.rb",[214,625,626,628],{"class":216,"style":217},[214,627,228],{"style":227},[214,629,630],{"style":231}," PendingAuthentication",[214,632,633,635,637,639],{"class":216,"style":217},[214,634,237],{"style":227},[214,636,241],{"style":240},[214,638,245],{"style":244},[214,640,248],{"style":240},[214,642],{"class":216,"style":217},[214,644,645,647],{"class":216,"style":217},[214,646,255],{"style":244},[214,648,258],{"style":227},[214,650,651,653],{"class":216,"style":217},[214,652,263],{"style":244},[214,654,655],{"style":240},":ensure_pending_authentication",[214,657,658],{"class":216,"style":217},[214,659,278],{"style":227},[214,661],{"class":216,"style":217},[214,663,664],{"class":216,"style":217},[214,665,285],{"style":227},[214,667],{"class":216,"style":217},[214,669,670,672],{"class":216,"style":217},[214,671,297],{"style":227},[214,673,674],{"style":300}," ensure_pending_authentication",[214,676,677,679,681,683,685,687,689,691],{"class":216,"style":217},[214,678,341],{"style":227},[214,680,344],{"style":227},[214,682,347],{"style":244},[214,684,320],{"style":240},[214,686,245],{"style":244},[214,688,325],{"style":240},[214,690,356],{"style":244},[214,692,693],{"style":300},"present?",[214,695],{"class":216,"style":217},[214,697,698,701,704],{"class":216,"style":217},[214,699,700],{"style":244},"    redirect_to new_user_session_path, ",[214,702,703],{"style":240},"alert:",[214,705,707],{"style":706},"color:#0A3069;--shiki-dark:#A5D6FF"," 'Please sign in first'",[214,709,710],{"class":216,"style":217},[214,711,278],{"style":227},[214,713],{"class":216,"style":217},[214,715,716,718],{"class":216,"style":217},[214,717,297],{"style":227},[214,719,720],{"style":300}," pending_user",[214,722,723,726,729,732,734,737,740,743,745,747,749,751,753,756],{"class":216,"style":217},[214,724,725],{"style":240},"    User",[214,727,728],{"style":244},".",[214,730,731],{"style":300},"find_by",[214,733,317],{"style":244},[214,735,736],{"style":240},"id:",[214,738,739],{"style":244}," session.",[214,741,742],{"style":300},"dig",[214,744,317],{"style":244},[214,746,320],{"style":240},[214,748,245],{"style":244},[214,750,325],{"style":240},[214,752,464],{"style":244},[214,754,755],{"style":706},"'user_id'",[214,757,758],{"style":244},"))",[214,760,761],{"class":216,"style":217},[214,762,278],{"style":227},[214,764],{"class":216,"style":217},[214,766,767,769,772],{"class":216,"style":217},[214,768,297],{"style":227},[214,770,771],{"style":300}," complete_sign_in",[214,773,774],{"style":244},"(user)",[214,776,777,780,783,785,787,789,791,793,795,797,800],{"class":216,"style":217},[214,778,779],{"style":231},"    stored_location",[214,781,782],{"style":227}," =",[214,784,739],{"style":244},[214,786,742],{"style":300},[214,788,317],{"style":244},[214,790,320],{"style":240},[214,792,245],{"style":244},[214,794,325],{"style":240},[214,796,464],{"style":244},[214,798,799],{"style":706},"'stored_location'",[214,801,802],{"style":244},")",[214,804,805,807,809,811,813,815,817],{"class":216,"style":217},[214,806,311],{"style":244},[214,808,314],{"style":300},[214,810,317],{"style":244},[214,812,320],{"style":240},[214,814,245],{"style":244},[214,816,325],{"style":240},[214,818,802],{"style":244},[214,820],{"class":216,"style":217},[214,822,823,826,828,831,834,836,839],{"class":216,"style":217},[214,824,825],{"style":300},"    store_location_for",[214,827,317],{"style":244},[214,829,830],{"style":240},":user",[214,832,833],{"style":244},", stored_location) ",[214,835,331],{"style":227},[214,837,838],{"style":244}," stored_location.",[214,840,693],{"style":300},[214,842],{"class":216,"style":217},[214,844,845,848,851,854,857],{"class":216,"style":217},[214,846,847],{"style":300},"    sign_in",[214,849,850],{"style":244},"(user, ",[214,852,853],{"style":240},"remember:",[214,855,856],{"style":240}," true",[214,858,802],{"style":244},[214,860],{"class":216,"style":217},[214,862,863,866,869],{"class":216,"style":217},[214,864,865],{"style":244},"    redirect_to ",[214,867,868],{"style":300},"after_sign_in_path_for",[214,870,774],{"style":244},[214,872,873],{"class":216,"style":217},[214,874,278],{"style":227},[214,876,877],{"class":216,"style":217},[214,878,375],{"style":227},[90,880,881],{},"Let's break down what each method does.",[90,883,884,887,888,891],{},[210,885,886],{},"ensure_pending_authentication"," is a before_action guard. It prevents users from accessing 2FA pages directly without first starting the authentication flow. If someone navigates to ",[210,889,890],{},"\u002Fweb_authn\u002Fauthentication\u002Fnew"," without a pending session, they get redirected to sign-in.",[90,893,894,897,898,901],{},[210,895,896],{},"pending_user"," retrieves the user from the session. During the 2FA flow, we store the user's ID (not the user object) in the session. This method looks them up. It returns ",[210,899,900],{},"nil"," if the user doesn't exist or if the session has expired.",[90,903,904,907,908,911],{},[210,905,906],{},"complete_sign_in"," finishes the authentication. It handles several things: restoring where the user was trying to go before authentication, cleaning up the pending session, and actually signing them in. Note that we always set ",[210,909,910],{},"remember: true",". This was a deliberate decision. Users who authenticate with passkeys have proven possession of a secure device, so there's no need to make them re-authenticate frequently.",[199,913,36],{"id":35},[90,915,916],{},"Add the authentication routes:",[205,918,919],{"language":207,"class":208},[210,920,921,222,926,222,937,222,942,222,944,222,958,222,960,222,970,222,985,222,989],{"class":212},[214,922,923],{"class":216,"style":217},[214,924,925],{"style":220},"# config\u002Froutes.rb",[214,927,928,931,934],{"class":216,"style":217},[214,929,930],{"style":244},"namespace ",[214,932,933],{"style":240},":web_authn",[214,935,936],{"style":227}," do",[214,938,939],{"class":216,"style":217},[214,940,941],{"style":220},"  # ... credentials routes from Part 1",[214,943],{"class":216,"style":217},[214,945,946,949,952,954,956],{"class":216,"style":217},[214,947,948],{"style":244},"  resource ",[214,950,951],{"style":240},":authentication",[214,953,464],{"style":244},[214,955,467],{"style":240},[214,957,501],{"style":240},[214,959],{"class":216,"style":217},[214,961,962,965,968],{"class":216,"style":217},[214,963,964],{"style":244},"  namespace ",[214,966,967],{"style":240},":authentications",[214,969,936],{"style":227},[214,971,972,975,978,980,982],{"class":216,"style":217},[214,973,974],{"style":244},"    resource ",[214,976,977],{"style":240},":challenge",[214,979,464],{"style":244},[214,981,467],{"style":240},[214,983,984],{"style":240}," :create",[214,986,987],{"class":216,"style":217},[214,988,278],{"style":227},[214,990,991],{"class":216,"style":217},[214,992,375],{"style":227},[90,994,995],{},"This gives us:",[997,998,999,1006,1012],"ul",{},[1000,1001,1002,1005],"li",{},[210,1003,1004],{},"GET \u002Fweb_authn\u002Fauthentication\u002Fnew"," - The 2FA page",[1000,1007,1008,1011],{},[210,1009,1010],{},"POST \u002Fweb_authn\u002Fauthentications\u002Fchallenge"," - Get authentication options (separate controller)",[1000,1013,1014,1017],{},[210,1015,1016],{},"POST \u002Fweb_authn\u002Fauthentication"," - Verify the passkey",[90,1019,1020],{},"We put the challenge in its own controller. It's a distinct responsibility (generating options) from the main authentication controller (verifying credentials). This follows the single-responsibility principle and keeps each controller focused.",[199,1022,39],{"id":38},[90,1024,1025],{},"We modify how Devise handles sign-in to redirect users with WebAuthn to the 2FA page after they enter their password:",[205,1027,1028],{"language":207,"class":208},[210,1029,1030,222,1035,222,1045,222,1057,222,1059,222,1066,222,1082,222,1084,222,1105,222,1113,222,1115,222,1126,222,1130,222,1132,222,1139,222,1152,222,1154,222,1165,222,1178,222,1188,222,1195,222,1200,222,1207,222,1212,222,1216,222,1218,222,1222,222,1224,222,1230,222,1254,222,1258,222,1260,222,1269,222,1278,222,1280,222,1300,222,1314,222,1331,222,1336,222,1338,222,1342,222,1346,222,1348,222,1357,222,1373,222,1375,222,1388,222,1401,222,1405],{"class":212},[214,1031,1032],{"class":216,"style":217},[214,1033,1034],{"style":220},"# app\u002Fcontrollers\u002Fusers\u002Fsessions_controller.rb",[214,1036,1037,1039,1041,1043],{"class":216,"style":217},[214,1038,392],{"style":227},[214,1040,449],{"style":231},[214,1042,398],{"style":244},[214,1044,454],{"style":240},[214,1046,1047,1049,1051,1053,1055],{"class":216,"style":217},[214,1048,459],{"style":244},[214,1050,273],{"style":240},[214,1052,464],{"style":244},[214,1054,467],{"style":240},[214,1056,470],{"style":240},[214,1058],{"class":216,"style":217},[214,1060,1061,1063],{"class":216,"style":217},[214,1062,297],{"style":227},[214,1064,1065],{"style":300}," new",[214,1067,1068,1070,1072,1074,1076,1078,1080],{"class":216,"style":217},[214,1069,311],{"style":244},[214,1071,314],{"style":300},[214,1073,317],{"style":244},[214,1075,320],{"style":240},[214,1077,245],{"style":244},[214,1079,325],{"style":240},[214,1081,802],{"style":244},[214,1083],{"class":216,"style":217},[214,1085,1086,1089,1091,1094,1096,1099,1102],{"class":216,"style":217},[214,1087,1088],{"style":240},"    self",[214,1090,728],{"style":244},[214,1092,1093],{"style":300},"resource",[214,1095,782],{"style":227},[214,1097,1098],{"style":244}," resource_class.",[214,1100,1101],{"style":227},"new",[214,1103,1104],{"style":244},"(sign_in_params)",[214,1106,1107,1110],{"class":216,"style":217},[214,1108,1109],{"style":300},"    clean_up_passwords",[214,1111,1112],{"style":244},"(resource)",[214,1114],{"class":216,"style":217},[214,1116,1117,1120,1123],{"class":216,"style":217},[214,1118,1119],{"style":244},"    render ",[214,1121,1122],{"style":240},"inertia:",[214,1124,1125],{"style":706}," 'auth\u002FSignIn'",[214,1127,1128],{"class":216,"style":217},[214,1129,278],{"style":227},[214,1131],{"class":216,"style":217},[214,1133,1134,1136],{"class":216,"style":217},[214,1135,297],{"style":227},[214,1137,1138],{"style":300}," create",[214,1140,1141,1143,1145,1147,1149],{"class":216,"style":217},[214,1142,1088],{"style":240},[214,1144,728],{"style":244},[214,1146,1093],{"style":300},[214,1148,782],{"style":227},[214,1150,1151],{"style":244}," authenticate_without_session",[214,1153],{"class":216,"style":217},[214,1155,1156,1159,1162],{"class":216,"style":217},[214,1157,1158],{"style":227},"    if",[214,1160,1161],{"style":244}," resource.",[214,1163,1164],{"style":300},"nil?",[214,1166,1167,1170,1172,1175],{"class":216,"style":217},[214,1168,1169],{"style":227},"      throw",[214,1171,317],{"style":244},[214,1173,1174],{"style":240},":warden",[214,1176,1177],{"style":244},", auth_options)",[214,1179,1180,1183,1185],{"class":216,"style":217},[214,1181,1182],{"style":227},"    elsif",[214,1184,1161],{"style":244},[214,1186,1187],{"style":300},"web_authn_enabled?",[214,1189,1190,1193],{"class":216,"style":217},[214,1191,1192],{"style":300},"      handle_web_authn_sign_in",[214,1194,1112],{"style":244},[214,1196,1197],{"class":216,"style":217},[214,1198,1199],{"style":227},"    else",[214,1201,1202,1205],{"class":216,"style":217},[214,1203,1204],{"style":300},"      handle_normal_sign_in",[214,1206,1112],{"style":244},[214,1208,1209],{"class":216,"style":217},[214,1210,1211],{"style":227},"    end",[214,1213,1214],{"class":216,"style":217},[214,1215,278],{"style":227},[214,1217],{"class":216,"style":217},[214,1219,1220],{"class":216,"style":217},[214,1221,285],{"style":227},[214,1223],{"class":216,"style":217},[214,1225,1226,1228],{"class":216,"style":217},[214,1227,297],{"style":227},[214,1229,1151],{"style":300},[214,1231,1232,1235,1238,1241,1244,1246,1249,1252],{"class":216,"style":217},[214,1233,1234],{"style":244},"    warden.",[214,1236,1237],{"style":300},"authenticate",[214,1239,1240],{"style":244},"(auth_options.",[214,1242,1243],{"style":300},"merge",[214,1245,317],{"style":244},[214,1247,1248],{"style":240},"store:",[214,1250,1251],{"style":240}," false",[214,1253,758],{"style":244},[214,1255,1256],{"class":216,"style":217},[214,1257,278],{"style":227},[214,1259],{"class":216,"style":217},[214,1261,1262,1264,1267],{"class":216,"style":217},[214,1263,297],{"style":227},[214,1265,1266],{"style":300}," handle_web_authn_sign_in",[214,1268,1112],{"style":244},[214,1270,1271,1274,1276],{"class":216,"style":217},[214,1272,1273],{"style":244},"    sign_out_all_scopes ",[214,1275,331],{"style":227},[214,1277,334],{"style":244},[214,1279],{"class":216,"style":217},[214,1281,1282,1285,1287,1289,1291,1294,1297],{"class":216,"style":217},[214,1283,1284],{"style":244},"    session[",[214,1286,320],{"style":240},[214,1288,245],{"style":244},[214,1290,325],{"style":240},[214,1292,1293],{"style":244},"] ",[214,1295,1296],{"style":227},"=",[214,1298,1299],{"style":244}," {",[214,1301,1302,1305,1308,1311],{"class":216,"style":217},[214,1303,1304],{"style":706},"      'user_id'",[214,1306,1307],{"style":244}," => resource.",[214,1309,1310],{"style":300},"id",[214,1312,1313],{"style":244},",",[214,1315,1316,1319,1322,1325,1327,1329],{"class":216,"style":217},[214,1317,1318],{"style":706},"      'stored_location'",[214,1320,1321],{"style":244}," => ",[214,1323,1324],{"style":300},"stored_location_for",[214,1326,317],{"style":244},[214,1328,830],{"style":240},[214,1330,802],{"style":244},[214,1332,1333],{"class":216,"style":217},[214,1334,1335],{"style":244},"    }",[214,1337],{"class":216,"style":217},[214,1339,1340],{"class":216,"style":217},[214,1341,366],{"style":244},[214,1343,1344],{"class":216,"style":217},[214,1345,278],{"style":227},[214,1347],{"class":216,"style":217},[214,1349,1350,1352,1355],{"class":216,"style":217},[214,1351,297],{"style":227},[214,1353,1354],{"style":300}," handle_normal_sign_in",[214,1356,1112],{"style":244},[214,1358,1359,1361,1363,1365,1367,1369,1371],{"class":216,"style":217},[214,1360,311],{"style":244},[214,1362,314],{"style":300},[214,1364,317],{"style":244},[214,1366,320],{"style":240},[214,1368,245],{"style":244},[214,1370,325],{"style":240},[214,1372,802],{"style":244},[214,1374],{"class":216,"style":217},[214,1376,1377,1379,1382,1384,1386],{"class":216,"style":217},[214,1378,847],{"style":300},[214,1380,1381],{"style":244},"(resource_name, resource, ",[214,1383,853],{"style":240},[214,1385,856],{"style":240},[214,1387,802],{"style":244},[214,1389,1390,1393,1396,1399],{"class":216,"style":217},[214,1391,1392],{"style":244},"    respond_with resource, ",[214,1394,1395],{"style":240},"location:",[214,1397,1398],{"style":300}," after_sign_in_path_for",[214,1400,1112],{"style":244},[214,1402,1403],{"class":216,"style":217},[214,1404,278],{"style":227},[214,1406,1407],{"class":216,"style":217},[214,1408,375],{"style":227},[90,1410,1411],{},"Let's walk through what this does.",[90,1413,1414,1415,1417],{},"First, we skip ",[210,1416,423],{}," for the sessions controller actions. This concern (defined earlier) would redirect users to 2FA, but we need to handle the sign-in flow ourselves here:",[205,1419,1420],{"language":207,"class":208},[210,1421,1422],{"class":212},[214,1423,1424,1427,1429,1431,1433],{"class":216,"style":217},[214,1425,1426],{"style":244},"skip_before_action ",[214,1428,273],{"style":240},[214,1430,464],{"style":244},[214,1432,467],{"style":240},[214,1434,470],{"style":240},[90,1436,420,1437,1439],{},[210,1438,1101],{}," action clears any stale WebAuthn session. This handles the case where a user abandons 2FA and comes back to the sign-in page.",[90,1441,166,1442,1445,1446,1449],{},[210,1443,1444],{},"create",", we use ",[210,1447,1448],{},"store: false"," to authenticate without creating a session. This verifies the password is correct but doesn't sign them in yet:",[205,1451,1452],{"language":207,"class":208},[210,1453,1454],{"class":212},[214,1455,1456,1459,1461,1463,1465,1468,1470,1472,1474,1476,1478,1480],{"class":216,"style":217},[214,1457,1458],{"style":240},"self",[214,1460,728],{"style":244},[214,1462,1093],{"style":300},[214,1464,782],{"style":227},[214,1466,1467],{"style":244}," warden.",[214,1469,1237],{"style":300},[214,1471,1240],{"style":244},[214,1473,1243],{"style":300},[214,1475,317],{"style":244},[214,1477,1248],{"style":240},[214,1479,1251],{"style":240},[214,1481,758],{"style":244},[90,1483,1484],{},"Then we check if the user has WebAuthn enabled. If they do, we redirect them to 2FA:",[205,1486,1487],{"language":207,"class":208},[210,1488,1489,222,1498,222,1507,222,1509,222,1526,222,1537,222,1552,222,1557,222,1559,222,1564],{"class":212},[214,1490,1491,1494,1496],{"class":216,"style":217},[214,1492,1493],{"style":227},"def",[214,1495,1266],{"style":300},[214,1497,1112],{"style":244},[214,1499,1500,1503,1505],{"class":216,"style":217},[214,1501,1502],{"style":244},"  sign_out_all_scopes ",[214,1504,331],{"style":227},[214,1506,334],{"style":244},[214,1508],{"class":216,"style":217},[214,1510,1511,1514,1516,1518,1520,1522,1524],{"class":216,"style":217},[214,1512,1513],{"style":244},"  session[",[214,1515,320],{"style":240},[214,1517,245],{"style":244},[214,1519,325],{"style":240},[214,1521,1293],{"style":244},[214,1523,1296],{"style":227},[214,1525,1299],{"style":244},[214,1527,1528,1531,1533,1535],{"class":216,"style":217},[214,1529,1530],{"style":706},"    'user_id'",[214,1532,1307],{"style":244},[214,1534,1310],{"style":300},[214,1536,1313],{"style":244},[214,1538,1539,1542,1544,1546,1548,1550],{"class":216,"style":217},[214,1540,1541],{"style":706},"    'stored_location'",[214,1543,1321],{"style":244},[214,1545,1324],{"style":300},[214,1547,317],{"style":244},[214,1549,830],{"style":240},[214,1551,802],{"style":244},[214,1553,1554],{"class":216,"style":217},[214,1555,1556],{"style":244},"  }",[214,1558],{"class":216,"style":217},[214,1560,1561],{"class":216,"style":217},[214,1562,1563],{"style":244},"  redirect_to new_web_authn_authentication_path",[214,1565,1566],{"class":216,"style":217},[214,1567,375],{"style":227},[90,1569,1570],{},"We store the user's ID and the location they were trying to access in the WebAuthn session. After they complete 2FA, we'll redirect them to that location.",[90,1572,1573,1574,1576],{},"For users without WebAuthn, we sign them in normally with ",[210,1575,910],{},". We decided not to show a \"remember me\" checkbox. With modern session security, keeping users signed in is the better UX.",[199,1578,42],{"id":41},[90,1580,1581],{},"The challenge is in its own controller. It generates authentication options:",[205,1583,1584],{"language":207,"class":208},[210,1585,1586,222,1591,222,1602,222,1608,222,1610,222,1616,222,1622,222,1628,222,1630,222,1654,222,1656,222,1662,222,1671,222,1673,222,1681,222,1710,222,1714,222,1716,222,1740,222,1764,222,1772,222,1777,222,1779,222,1805,222,1807,222,1816,222,1820],{"class":212},[214,1587,1588],{"class":216,"style":217},[214,1589,1590],{"style":220},"# app\u002Fcontrollers\u002Fweb_authn\u002Fauthentications\u002Fchallenges_controller.rb",[214,1592,1593,1595,1598,1600],{"class":216,"style":217},[214,1594,392],{"style":227},[214,1596,1597],{"style":231}," WebAuthn::Authentications::ChallengesController",[214,1599,398],{"style":244},[214,1601,596],{"style":240},[214,1603,1604,1606],{"class":216,"style":217},[214,1605,406],{"style":227},[214,1607,630],{"style":240},[214,1609],{"class":216,"style":217},[214,1611,1612,1614],{"class":216,"style":217},[214,1613,459],{"style":244},[214,1615,655],{"style":240},[214,1617,1618,1620],{"class":216,"style":217},[214,1619,459],{"style":244},[214,1621,266],{"style":240},[214,1623,1624,1626],{"class":216,"style":217},[214,1625,459],{"style":244},[214,1627,273],{"style":240},[214,1629],{"class":216,"style":217},[214,1631,1632,1635,1638,1641,1643,1646,1649,1651],{"class":216,"style":217},[214,1633,1634],{"style":244},"  rate_limit ",[214,1636,1637],{"style":240},"to:",[214,1639,1640],{"style":240}," 5",[214,1642,464],{"style":244},[214,1644,1645],{"style":240},"within:",[214,1647,1648],{"style":240}," 1",[214,1650,728],{"style":244},[214,1652,1653],{"style":300},"minute",[214,1655],{"class":216,"style":217},[214,1657,1658,1660],{"class":216,"style":217},[214,1659,297],{"style":227},[214,1661,1138],{"style":300},[214,1663,1664,1667,1669],{"class":216,"style":217},[214,1665,1666],{"style":231},"    user",[214,1668,782],{"style":227},[214,1670,720],{"style":244},[214,1672],{"class":216,"style":217},[214,1674,1675,1678],{"class":216,"style":217},[214,1676,1677],{"style":227},"    unless",[214,1679,1680],{"style":244}," user",[214,1682,1683,1686,1689,1692,1695,1698,1701,1704,1707],{"class":216,"style":217},[214,1684,1685],{"style":227},"      return",[214,1687,1688],{"style":244}," render ",[214,1690,1691],{"style":240},"json:",[214,1693,1694],{"style":244}," { ",[214,1696,1697],{"style":240},"error:",[214,1699,1700],{"style":706}," 'Session expired'",[214,1702,1703],{"style":244}," }, ",[214,1705,1706],{"style":240},"status:",[214,1708,1709],{"style":240}," :unprocessable_content",[214,1711,1712],{"class":216,"style":217},[214,1713,1211],{"style":227},[214,1715],{"class":216,"style":217},[214,1717,1718,1721,1723,1726,1728,1730,1733,1735,1738],{"class":216,"style":217},[214,1719,1720],{"style":231},"    options",[214,1722,782],{"style":227},[214,1724,1725],{"style":244}," ::",[214,1727,320],{"style":240},[214,1729,245],{"style":244},[214,1731,1732],{"style":240},"Credential",[214,1734,728],{"style":244},[214,1736,1737],{"style":300},"options_for_get",[214,1739,317],{"style":244},[214,1741,1742,1745,1748,1751,1753,1756,1758,1761],{"class":216,"style":217},[214,1743,1744],{"style":240},"      allow:",[214,1746,1747],{"style":244}," user.",[214,1749,1750],{"style":300},"web_authn_credentials",[214,1752,728],{"style":244},[214,1754,1755],{"style":300},"pluck",[214,1757,317],{"style":244},[214,1759,1760],{"style":240},":external_id",[214,1762,1763],{"style":244},"),",[214,1765,1766,1769],{"class":216,"style":217},[214,1767,1768],{"style":240},"      user_verification:",[214,1770,1771],{"style":706}," 'discouraged'",[214,1773,1774],{"class":216,"style":217},[214,1775,1776],{"style":244},"    )",[214,1778],{"class":216,"style":217},[214,1780,1781,1783,1785,1787,1789,1792,1795,1797,1799,1802],{"class":216,"style":217},[214,1782,1284],{"style":244},[214,1784,320],{"style":240},[214,1786,245],{"style":244},[214,1788,325],{"style":240},[214,1790,1791],{"style":244},"][",[214,1793,1794],{"style":706},"'challenge'",[214,1796,1293],{"style":244},[214,1798,1296],{"style":227},[214,1800,1801],{"style":244}," options.",[214,1803,1804],{"style":300},"challenge",[214,1806],{"class":216,"style":217},[214,1808,1809,1811,1813],{"class":216,"style":217},[214,1810,1119],{"style":244},[214,1812,1691],{"style":240},[214,1814,1815],{"style":244}," options",[214,1817,1818],{"class":216,"style":217},[214,1819,278],{"style":227},[214,1821,1822],{"class":216,"style":217},[214,1823,375],{"style":227},[90,1825,1826,1827,1829,1830,1833,1834,1837],{},"Unlike registration, authentication uses ",[210,1828,1737],{},". The ",[210,1831,1832],{},"allow"," parameter restricts which credentials can be used. The ",[210,1835,1836],{},"user_verification: 'discouraged'"," setting matches what we used during registration. For 2FA, the password already provides one factor, so we only need the authenticator to prove presence (touch), not verify the user's identity again with a PIN or biometric. If a user has multiple passkeys, any of them will work. We store the challenge in the existing WebAuthn session.",[199,1839,45],{"id":44},[90,1841,1842],{},"Now the controller that verifies the passkey:",[205,1844,1845],{"language":207,"class":208},[210,1846,1847,222,1852,222,1862,222,1868,222,1870,222,1890,222,1896,222,1902,222,1904,222,1934,222,1936,222,1942,222,1951,222,1955,222,1957,222,1963,222,1971,222,1973,222,1985,222,1999,222,2001,222,2008,222,2025,222,2030,222,2055,222,2059,222,2061,222,2065,222,2067,222,2074,222,2090,222,2099,222,2103,222,2105,222,2112,222,2116,222,2125,222,2129,222,2131,222,2139,222,2162,222,2189,222,2191,222,2203,222,2205,222,2215,222,2236,222,2249,222,2259,222,2263,222,2265,222,2284,222,2289,222,2293,222,2295,222,2302,222,2325,222,2329,222,2331,222,2338,222,2348,222,2355,222,2377,222,2391,222,2396,222,2400,222,2404],{"class":212},[214,1848,1849],{"class":216,"style":217},[214,1850,1851],{"style":220},"# app\u002Fcontrollers\u002Fweb_authn\u002Fauthentications_controller.rb",[214,1853,1854,1856,1858,1860],{"class":216,"style":217},[214,1855,392],{"style":227},[214,1857,591],{"style":231},[214,1859,398],{"style":244},[214,1861,596],{"style":240},[214,1863,1864,1866],{"class":216,"style":217},[214,1865,406],{"style":227},[214,1867,630],{"style":240},[214,1869],{"class":216,"style":217},[214,1871,1872,1874,1877,1879,1881,1884,1887],{"class":216,"style":217},[214,1873,459],{"style":244},[214,1875,1876],{"style":240},":underscore_params",[214,1878,464],{"style":244},[214,1880,467],{"style":240},[214,1882,1883],{"style":244}," [",[214,1885,1886],{"style":240},":create",[214,1888,1889],{"style":244},"]",[214,1891,1892,1894],{"class":216,"style":217},[214,1893,459],{"style":244},[214,1895,266],{"style":240},[214,1897,1898,1900],{"class":216,"style":217},[214,1899,459],{"style":244},[214,1901,273],{"style":240},[214,1903],{"class":216,"style":217},[214,1905,1906,1908,1910,1912,1914,1916,1918,1920,1922,1924,1927,1929,1932],{"class":216,"style":217},[214,1907,1634],{"style":244},[214,1909,1637],{"style":240},[214,1911,1640],{"style":240},[214,1913,464],{"style":244},[214,1915,1645],{"style":240},[214,1917,1648],{"style":240},[214,1919,728],{"style":244},[214,1921,1653],{"style":300},[214,1923,464],{"style":244},[214,1925,1926],{"style":240},"except:",[214,1928,1883],{"style":244},[214,1930,1931],{"style":240},":new",[214,1933,1889],{"style":244},[214,1935],{"class":216,"style":217},[214,1937,1938,1940],{"class":216,"style":217},[214,1939,297],{"style":227},[214,1941,1065],{"style":300},[214,1943,1944,1946,1948],{"class":216,"style":217},[214,1945,1119],{"style":244},[214,1947,1122],{"style":240},[214,1949,1950],{"style":706}," 'auth\u002FTwoFactorAuth'",[214,1952,1953],{"class":216,"style":217},[214,1954,278],{"style":227},[214,1956],{"class":216,"style":217},[214,1958,1959,1961],{"class":216,"style":217},[214,1960,297],{"style":227},[214,1962,1138],{"style":300},[214,1964,1965,1967,1969],{"class":216,"style":217},[214,1966,1666],{"style":231},[214,1968,782],{"style":227},[214,1970,720],{"style":244},[214,1972],{"class":216,"style":217},[214,1974,1975,1977,1980,1983],{"class":216,"style":217},[214,1976,341],{"style":227},[214,1978,1979],{"style":244}," handle_expired_session ",[214,1981,1982],{"style":227},"unless",[214,1984,1680],{"style":244},[214,1986,1987,1989,1992,1994,1997],{"class":216,"style":217},[214,1988,341],{"style":227},[214,1990,1991],{"style":244}," handle_unrecognized_passkey ",[214,1993,1982],{"style":227},[214,1995,1996],{"style":300}," valid_credential?",[214,1998,774],{"style":244},[214,2000],{"class":216,"style":217},[214,2002,2003,2006],{"class":216,"style":217},[214,2004,2005],{"style":300},"    complete_sign_in",[214,2007,774],{"style":244},[214,2009,2010,2013,2015,2017,2019,2022],{"class":216,"style":217},[214,2011,2012],{"style":227},"  rescue",[214,2014,1725],{"style":244},[214,2016,320],{"style":240},[214,2018,245],{"style":244},[214,2020,2021],{"style":240},"Error",[214,2023,2024],{"style":244}," => e",[214,2026,2027],{"class":216,"style":217},[214,2028,2029],{"style":244},"    clear_challenge",[214,2031,2032,2035,2037,2040,2043,2046,2049,2052],{"class":216,"style":217},[214,2033,2034],{"style":244},"    redirect_to new_web_authn_authentication_path, ",[214,2036,703],{"style":240},[214,2038,2039],{"style":706}," \"Verification failed: ",[214,2041,2042],{"style":227},"#{",[214,2044,2045],{"style":706},"e.",[214,2047,2048],{"style":300},"message",[214,2050,2051],{"style":227},"}",[214,2053,2054],{"style":706},"\"",[214,2056,2057],{"class":216,"style":217},[214,2058,278],{"style":227},[214,2060],{"class":216,"style":217},[214,2062,2063],{"class":216,"style":217},[214,2064,285],{"style":227},[214,2066],{"class":216,"style":217},[214,2068,2069,2071],{"class":216,"style":217},[214,2070,297],{"style":227},[214,2072,2073],{"style":300}," handle_expired_session",[214,2075,2076,2078,2080,2082,2084,2086,2088],{"class":216,"style":217},[214,2077,311],{"style":244},[214,2079,314],{"style":300},[214,2081,317],{"style":244},[214,2083,320],{"style":240},[214,2085,245],{"style":244},[214,2087,325],{"style":240},[214,2089,802],{"style":244},[214,2091,2092,2094,2096],{"class":216,"style":217},[214,2093,700],{"style":244},[214,2095,703],{"style":240},[214,2097,2098],{"style":706}," 'Session expired. Please sign in again.'",[214,2100,2101],{"class":216,"style":217},[214,2102,278],{"style":227},[214,2104],{"class":216,"style":217},[214,2106,2107,2109],{"class":216,"style":217},[214,2108,297],{"style":227},[214,2110,2111],{"style":300}," handle_unrecognized_passkey",[214,2113,2114],{"class":216,"style":217},[214,2115,2029],{"style":244},[214,2117,2118,2120,2122],{"class":216,"style":217},[214,2119,700],{"style":244},[214,2121,703],{"style":240},[214,2123,2124],{"style":706}," 'Passkey not recognized'",[214,2126,2127],{"class":216,"style":217},[214,2128,278],{"style":227},[214,2130],{"class":216,"style":217},[214,2132,2133,2135,2137],{"class":216,"style":217},[214,2134,297],{"style":227},[214,2136,1996],{"style":300},[214,2138,774],{"style":244},[214,2140,2141,2144,2146,2148,2150,2152,2154,2156,2159],{"class":216,"style":217},[214,2142,2143],{"style":231},"    web_authn_credential",[214,2145,782],{"style":227},[214,2147,1725],{"style":244},[214,2149,320],{"style":240},[214,2151,245],{"style":244},[214,2153,1732],{"style":240},[214,2155,728],{"style":244},[214,2157,2158],{"style":300},"from_get",[214,2160,2161],{"style":244},"(credential_params)",[214,2163,2164,2167,2169,2171,2173,2175,2177,2179,2182,2185,2187],{"class":216,"style":217},[214,2165,2166],{"style":231},"    stored_credential",[214,2168,782],{"style":227},[214,2170,1747],{"style":244},[214,2172,1750],{"style":300},[214,2174,728],{"style":244},[214,2176,731],{"style":300},[214,2178,317],{"style":244},[214,2180,2181],{"style":240},"external_id:",[214,2183,2184],{"style":244}," web_authn_credential.",[214,2186,1310],{"style":300},[214,2188,802],{"style":244},[214,2190],{"class":216,"style":217},[214,2192,2193,2195,2197,2200],{"class":216,"style":217},[214,2194,341],{"style":227},[214,2196,1251],{"style":240},[214,2198,2199],{"style":227}," unless",[214,2201,2202],{"style":244}," stored_credential",[214,2204],{"class":216,"style":217},[214,2206,2207,2210,2213],{"class":216,"style":217},[214,2208,2209],{"style":244},"    web_authn_credential.",[214,2211,2212],{"style":300},"verify",[214,2214,317],{"style":244},[214,2216,2217,2220,2222,2224,2226,2228,2230,2232,2234],{"class":216,"style":217},[214,2218,2219],{"style":244},"      session.",[214,2221,742],{"style":300},[214,2223,317],{"style":244},[214,2225,320],{"style":240},[214,2227,245],{"style":244},[214,2229,325],{"style":240},[214,2231,464],{"style":244},[214,2233,1794],{"style":706},[214,2235,1763],{"style":244},[214,2237,2238,2241,2244,2247],{"class":216,"style":217},[214,2239,2240],{"style":240},"      public_key:",[214,2242,2243],{"style":244}," stored_credential.",[214,2245,2246],{"style":300},"public_key",[214,2248,1313],{"style":244},[214,2250,2251,2254,2256],{"class":216,"style":217},[214,2252,2253],{"style":240},"      sign_count:",[214,2255,2243],{"style":244},[214,2257,2258],{"style":300},"sign_count",[214,2260,2261],{"class":216,"style":217},[214,2262,1776],{"style":244},[214,2264],{"class":216,"style":217},[214,2266,2267,2270,2273,2275,2278,2280,2282],{"class":216,"style":217},[214,2268,2269],{"style":244},"    stored_credential.",[214,2271,2272],{"style":300},"update!",[214,2274,317],{"style":244},[214,2276,2277],{"style":240},"sign_count:",[214,2279,2184],{"style":244},[214,2281,2258],{"style":300},[214,2283,802],{"style":244},[214,2285,2286],{"class":216,"style":217},[214,2287,2288],{"style":240},"    true",[214,2290,2291],{"class":216,"style":217},[214,2292,278],{"style":227},[214,2294],{"class":216,"style":217},[214,2296,2297,2299],{"class":216,"style":217},[214,2298,297],{"style":227},[214,2300,2301],{"style":300}," clear_challenge",[214,2303,2304,2306,2308,2310,2312,2314,2317,2319,2321,2323],{"class":216,"style":217},[214,2305,1284],{"style":244},[214,2307,320],{"style":240},[214,2309,245],{"style":244},[214,2311,325],{"style":240},[214,2313,1889],{"style":244},[214,2315,2316],{"style":227},"&.",[214,2318,314],{"style":300},[214,2320,317],{"style":244},[214,2322,1794],{"style":706},[214,2324,802],{"style":244},[214,2326,2327],{"class":216,"style":217},[214,2328,278],{"style":227},[214,2330],{"class":216,"style":217},[214,2332,2333,2335],{"class":216,"style":217},[214,2334,297],{"style":227},[214,2336,2337],{"style":300}," credential_params",[214,2339,2340,2343,2346],{"class":216,"style":217},[214,2341,2342],{"style":244},"    params.",[214,2344,2345],{"style":300},"expect",[214,2347,317],{"style":244},[214,2349,2350,2353],{"class":216,"style":217},[214,2351,2352],{"style":240},"      credential:",[214,2354,1883],{"style":244},[214,2356,2357,2360,2362,2365,2367,2370,2372,2375],{"class":216,"style":217},[214,2358,2359],{"style":240},"        :id",[214,2361,464],{"style":244},[214,2363,2364],{"style":240},":type",[214,2366,464],{"style":244},[214,2368,2369],{"style":240},":rawId",[214,2371,464],{"style":244},[214,2373,2374],{"style":240},":authenticatorAttachment",[214,2376,1313],{"style":244},[214,2378,2379,2382,2385,2388],{"class":216,"style":217},[214,2380,2381],{"style":244},"        { ",[214,2383,2384],{"style":240},"response:",[214,2386,2387],{"style":240}," %i[clientDataJSON authenticatorData signature userHandle]",[214,2389,2390],{"style":244}," }",[214,2392,2393],{"class":216,"style":217},[214,2394,2395],{"style":244},"      ]",[214,2397,2398],{"class":216,"style":217},[214,2399,1776],{"style":244},[214,2401,2402],{"class":216,"style":217},[214,2403,278],{"style":227},[214,2405,2406],{"class":216,"style":217},[214,2407,375],{"style":227},[90,2409,2410],{},"Let's break down each piece.",[90,2412,2413,2414,2417,2418,2421],{},"We skip ",[210,2415,2416],{},"authenticate_user!"," because users aren't signed in yet. We skip ",[210,2419,2420],{},"underscore_params"," because the WebAuthn gem needs camelCase keys.",[90,2423,420,2424,2426],{},[210,2425,1101],{}," action renders the 2FA page.",[90,2428,420,2429,2431],{},[210,2430,1444],{}," action verifies the response defensively. Check if the user exists. Check if verification succeeds. Only then sign them in:",[205,2433,2434],{"language":207,"class":208},[210,2435,2436,222,2447,222,2459,222,2461],{"class":212},[214,2437,2438,2441,2443,2445],{"class":216,"style":217},[214,2439,2440],{"style":227},"return",[214,2442,1979],{"style":244},[214,2444,1982],{"style":227},[214,2446,1680],{"style":244},[214,2448,2449,2451,2453,2455,2457],{"class":216,"style":217},[214,2450,2440],{"style":227},[214,2452,1991],{"style":244},[214,2454,1982],{"style":227},[214,2456,1996],{"style":300},[214,2458,774],{"style":244},[214,2460],{"class":216,"style":217},[214,2462,2463,2465],{"class":216,"style":217},[214,2464,906],{"style":300},[214,2466,774],{"style":244},[90,2468,420,2469,2472],{},[210,2470,2471],{},"valid_credential?"," method does the cryptographic verification and returns a boolean:",[2474,2475,2476,2479,2482,2485],"ol",{},[1000,2477,2478],{},"Parse the credential from the browser",[1000,2480,2481],{},"Find the stored credential by external_id",[1000,2483,2484],{},"Verify the signature against the stored public key and challenge",[1000,2486,2487],{},"Update the sign count",[90,2489,2490],{},"The sign count update is important for detecting cloned authenticators:",[205,2492,2493],{"language":207,"class":208},[210,2494,2495],{"class":212},[214,2496,2497,2500,2502,2504,2506,2508,2510],{"class":216,"style":217},[214,2498,2499],{"style":244},"stored_credential.",[214,2501,2272],{"style":300},[214,2503,317],{"style":244},[214,2505,2277],{"style":240},[214,2507,2184],{"style":244},[214,2509,2258],{"style":300},[214,2511,802],{"style":244},[90,2513,2514],{},"If someone clones a hardware key, the sign counts will diverge. The legitimate key might have sign_count 50, but the clone starts at 0. The verification will fail because the presented count is lower than expected.",[199,2516,48],{"id":47},[90,2518,2519,2520,2523],{},"The 2FA page needs to handle several states: loading, authenticating, errors, and a fallback to backup codes (which we'll add later in ",[124,2521,2522],{"href":151},"Part 3","). Let's build it up:",[205,2525,2527],{"language":2526,"class":208},"vue",[210,2528,2530,222,2553,222,2567,222,2579,222,2591,222,2597,222,2602,222,2607,222,2612,222,2622,222,2634,222,2636,222,2641,222,2661,222,2679,222,2709,222,2711,222,2716,222,2734,222,2747,222,2749,222,2754,222,2759,222,2767,222,2777,222,2781,222,2786],{"class":2529},"language-vue",[214,2531,2532,2535,2539,2542,2545,2547,2550],{"class":216,"style":217},[214,2533,2534],{"style":244},"\u003C",[214,2536,2538],{"style":2537},"color:#116329;--shiki-dark:#7EE787","script",[214,2540,2541],{"style":240}," setup",[214,2543,2544],{"style":240}," lang",[214,2546,1296],{"style":244},[214,2548,2549],{"style":706},"\"ts\"",[214,2551,2552],{"style":244},">",[214,2554,2555,2558,2561,2564],{"class":216,"style":217},[214,2556,2557],{"style":227},"import",[214,2559,2560],{"style":244}," { router } ",[214,2562,2563],{"style":227},"from",[214,2565,2566],{"style":706}," '@inertiajs\u002Fvue3'",[214,2568,2569,2571,2574,2576],{"class":216,"style":217},[214,2570,2557],{"style":227},[214,2572,2573],{"style":244}," { browserSupportsWebAuthn, startAuthentication } ",[214,2575,2563],{"style":227},[214,2577,2578],{"style":706}," '@simplewebauthn\u002Fbrowser'",[214,2580,2581,2583,2586,2588],{"class":216,"style":217},[214,2582,2557],{"style":227},[214,2584,2585],{"style":244}," { onMounted, ref } ",[214,2587,2563],{"style":227},[214,2589,2590],{"style":706}," 'vue'",[214,2592,2593,2595],{"class":216,"style":217},[214,2594,2557],{"style":227},[214,2596,1299],{"style":244},[214,2598,2599],{"class":216,"style":217},[214,2600,2601],{"style":244},"  new_user_session_path,",[214,2603,2604],{"class":216,"style":217},[214,2605,2606],{"style":244},"  web_authn_authentication_path,",[214,2608,2609],{"class":216,"style":217},[214,2610,2611],{"style":244},"  web_authn_authentications_challenge_path",[214,2613,2614,2617,2619],{"class":216,"style":217},[214,2615,2616],{"style":244},"} ",[214,2618,2563],{"style":227},[214,2620,2621],{"style":706}," '~\u002Froutes.js'",[214,2623,2624,2626,2629,2631],{"class":216,"style":217},[214,2625,2557],{"style":227},[214,2627,2628],{"style":244}," { getCsrfToken } ",[214,2630,2563],{"style":227},[214,2632,2633],{"style":706}," '~\u002Futils\u002Fcsrf'",[214,2635],{"class":216,"style":217},[214,2637,2638],{"class":216,"style":217},[214,2639,2640],{"style":220},"\u002F\u002F State management",[214,2642,2643,2646,2649,2651,2654,2656,2659],{"class":216,"style":217},[214,2644,2645],{"style":227},"const",[214,2647,2648],{"style":240}," isSupported",[214,2650,782],{"style":227},[214,2652,2653],{"style":300}," ref",[214,2655,317],{"style":244},[214,2657,2658],{"style":240},"true",[214,2660,802],{"style":244},[214,2662,2663,2665,2668,2670,2672,2674,2677],{"class":216,"style":217},[214,2664,2645],{"style":227},[214,2666,2667],{"style":240}," isAuthenticating",[214,2669,782],{"style":227},[214,2671,2653],{"style":300},[214,2673,317],{"style":244},[214,2675,2676],{"style":240},"false",[214,2678,802],{"style":244},[214,2680,2681,2683,2686,2688,2690,2692,2695,2698,2701,2704,2707],{"class":216,"style":217},[214,2682,2645],{"style":227},[214,2684,2685],{"style":240}," error",[214,2687,782],{"style":227},[214,2689,2653],{"style":300},[214,2691,2534],{"style":244},[214,2693,2694],{"style":240},"string",[214,2696,2697],{"style":227}," |",[214,2699,2700],{"style":240}," null",[214,2702,2703],{"style":244},">(",[214,2705,2706],{"style":240},"null",[214,2708,802],{"style":244},[214,2710],{"class":216,"style":217},[214,2712,2713],{"class":216,"style":217},[214,2714,2715],{"style":220},"\u002F\u002F Check WebAuthn support and auto-start authentication",[214,2717,2718,2721,2723,2726,2729,2732],{"class":216,"style":217},[214,2719,2720],{"style":300},"onMounted",[214,2722,317],{"style":244},[214,2724,2725],{"style":227},"async",[214,2727,2728],{"style":244}," () ",[214,2730,2731],{"style":227},"=>",[214,2733,1299],{"style":244},[214,2735,2736,2739,2741,2744],{"class":216,"style":217},[214,2737,2738],{"style":244},"  isSupported.value ",[214,2740,1296],{"style":227},[214,2742,2743],{"style":300}," browserSupportsWebAuthn",[214,2745,2746],{"style":244},"()",[214,2748],{"class":216,"style":217},[214,2750,2751],{"class":216,"style":217},[214,2752,2753],{"style":220},"  \u002F\u002F Auto-start WebAuthn authentication if supported",[214,2755,2756],{"class":216,"style":217},[214,2757,2758],{"style":220},"  \u002F\u002F This is key for good UX - users don't need to click another button",[214,2760,2761,2764],{"class":216,"style":217},[214,2762,2763],{"style":227},"  if",[214,2765,2766],{"style":244}," (isSupported.value) {",[214,2768,2769,2772,2775],{"class":216,"style":217},[214,2770,2771],{"style":227},"    await",[214,2773,2774],{"style":300}," authenticate",[214,2776,2746],{"style":244},[214,2778,2779],{"class":216,"style":217},[214,2780,1556],{"style":244},[214,2782,2783],{"class":216,"style":217},[214,2784,2785],{"style":244},"})",[214,2787,2788,2791,2793],{"class":216,"style":217},[214,2789,2790],{"style":244},"\u003C\u002F",[214,2792,2538],{"style":2537},[214,2794,2552],{"style":244},[90,2796,2797],{},"We check browser support on mount and immediately start authentication if supported. This reduces friction. Users don't have to click \"Sign in with passkey\" after already entering their password.",[90,2799,2800],{},"The authentication function:",[205,2802,2803],{"language":2526,"class":208},[210,2804,2805,222,2821,222,2826,222,2828,222,2840,222,2849,222,2858,222,2860,222,2867,222,2872,222,2877,222,2882,222,2906,222,2916,222,2921,222,2934,222,2946,222,2951,222,2956,222,2958,222,2971,222,2991,222,3011,222,3015,222,3017,222,3034,222,3036,222,3041,222,3046,222,3051,222,3068,222,3070,222,3075,222,3080,222,3095,222,3120,222,3124,222,3135,222,3140,222,3155,222,3171,222,3176,222,3186,222,3196,222,3205,222,3209,222,3218,222,3228,222,3232,222,3241,222,3245,222,3249,222,3251,222,3256,222,3261,222,3271,222,3287,222,3291],{"class":2529},[214,2806,2807,2809,2811,2813,2815,2817,2819],{"class":216,"style":217},[214,2808,2534],{"style":244},[214,2810,2538],{"style":2537},[214,2812,2541],{"style":240},[214,2814,2544],{"style":240},[214,2816,1296],{"style":244},[214,2818,2549],{"style":706},[214,2820,2552],{"style":244},[214,2822,2823],{"class":216,"style":217},[214,2824,2825],{"style":220},"\u002F\u002F ... previous code",[214,2827],{"class":216,"style":217},[214,2829,2830,2832,2835,2837],{"class":216,"style":217},[214,2831,2725],{"style":227},[214,2833,2834],{"style":227}," function",[214,2836,2774],{"style":300},[214,2838,2839],{"style":244},"() {",[214,2841,2842,2845,2847],{"class":216,"style":217},[214,2843,2844],{"style":244},"  isAuthenticating.value ",[214,2846,1296],{"style":227},[214,2848,856],{"style":240},[214,2850,2851,2854,2856],{"class":216,"style":217},[214,2852,2853],{"style":244},"  error.value ",[214,2855,1296],{"style":227},[214,2857,2700],{"style":240},[214,2859],{"class":216,"style":217},[214,2861,2862,2865],{"class":216,"style":217},[214,2863,2864],{"style":227},"  try",[214,2866,1299],{"style":244},[214,2868,2869],{"class":216,"style":217},[214,2870,2871],{"style":220},"    \u002F\u002F Step 1: Get challenge from server",[214,2873,2874],{"class":216,"style":217},[214,2875,2876],{"style":220},"    \u002F\u002F This is a separate request from the actual authentication",[214,2878,2879],{"class":216,"style":217},[214,2880,2881],{"style":220},"    \u002F\u002F because we need the server to generate a fresh challenge",[214,2883,2884,2887,2890,2892,2895,2898,2900,2903],{"class":216,"style":217},[214,2885,2886],{"style":227},"    const",[214,2888,2889],{"style":240}," challengeResponse",[214,2891,782],{"style":227},[214,2893,2894],{"style":227}," await",[214,2896,2897],{"style":300}," fetch",[214,2899,317],{"style":244},[214,2901,2902],{"style":300},"web_authn_authentications_challenge_path",[214,2904,2905],{"style":244},"(), {",[214,2907,2908,2911,2914],{"class":216,"style":217},[214,2909,2910],{"style":244},"      method: ",[214,2912,2913],{"style":706},"'POST'",[214,2915,1313],{"style":244},[214,2917,2918],{"class":216,"style":217},[214,2919,2920],{"style":244},"      headers: {",[214,2922,2923,2926,2929,2932],{"class":216,"style":217},[214,2924,2925],{"style":706},"        'Content-Type'",[214,2927,2928],{"style":244},": ",[214,2930,2931],{"style":706},"'application\u002Fjson'",[214,2933,1313],{"style":244},[214,2935,2936,2939,2941,2944],{"class":216,"style":217},[214,2937,2938],{"style":706},"        'X-CSRF-Token'",[214,2940,2928],{"style":244},[214,2942,2943],{"style":300},"getCsrfToken",[214,2945,2746],{"style":244},[214,2947,2948],{"class":216,"style":217},[214,2949,2950],{"style":244},"      }",[214,2952,2953],{"class":216,"style":217},[214,2954,2955],{"style":244},"    })",[214,2957],{"class":216,"style":217},[214,2959,2960,2962,2965,2968],{"class":216,"style":217},[214,2961,1158],{"style":227},[214,2963,2964],{"style":244}," (",[214,2966,2967],{"style":227},"!",[214,2969,2970],{"style":244},"challengeResponse.ok) {",[214,2972,2973,2976,2979,2981,2983,2986,2989],{"class":216,"style":217},[214,2974,2975],{"style":227},"      const",[214,2977,2978],{"style":240}," data",[214,2980,782],{"style":227},[214,2982,2894],{"style":227},[214,2984,2985],{"style":244}," challengeResponse.",[214,2987,2988],{"style":300},"json",[214,2990,2746],{"style":244},[214,2992,2993,2995,2997,3000,3003,3006,3009],{"class":216,"style":217},[214,2994,1169],{"style":227},[214,2996,1065],{"style":227},[214,2998,2999],{"style":300}," Error",[214,3001,3002],{"style":244},"(data.error ",[214,3004,3005],{"style":227},"||",[214,3007,3008],{"style":706}," 'Failed to get authentication challenge'",[214,3010,802],{"style":244},[214,3012,3013],{"class":216,"style":217},[214,3014,1335],{"style":244},[214,3016],{"class":216,"style":217},[214,3018,3019,3021,3024,3026,3028,3030,3032],{"class":216,"style":217},[214,3020,2886],{"style":227},[214,3022,3023],{"style":240}," optionsJSON",[214,3025,782],{"style":227},[214,3027,2894],{"style":227},[214,3029,2985],{"style":244},[214,3031,2988],{"style":300},[214,3033,2746],{"style":244},[214,3035],{"class":216,"style":217},[214,3037,3038],{"class":216,"style":217},[214,3039,3040],{"style":220},"    \u002F\u002F Step 2: Start browser authentication",[214,3042,3043],{"class":216,"style":217},[214,3044,3045],{"style":220},"    \u002F\u002F This triggers the browser's native passkey UI",[214,3047,3048],{"class":216,"style":217},[214,3049,3050],{"style":220},"    \u002F\u002F The user will see a prompt to use Touch ID, Face ID, etc.",[214,3052,3053,3055,3058,3060,3062,3065],{"class":216,"style":217},[214,3054,2886],{"style":227},[214,3056,3057],{"style":240}," authResponse",[214,3059,782],{"style":227},[214,3061,2894],{"style":227},[214,3063,3064],{"style":300}," startAuthentication",[214,3066,3067],{"style":244},"({ optionsJSON })",[214,3069],{"class":216,"style":217},[214,3071,3072],{"class":216,"style":217},[214,3073,3074],{"style":220},"    \u002F\u002F Step 3: Send to server for verification",[214,3076,3077],{"class":216,"style":217},[214,3078,3079],{"style":220},"    \u002F\u002F We use Inertia here so we get proper redirects on success",[214,3081,3082,3085,3088,3090,3093],{"class":216,"style":217},[214,3083,3084],{"style":244},"    router.",[214,3086,3087],{"style":300},"post",[214,3089,317],{"style":244},[214,3091,3092],{"style":300},"web_authn_authentication_path",[214,3094,2905],{"style":244},[214,3096,3097,3100,3103,3105,3108,3110,3112,3114,3117],{"class":216,"style":217},[214,3098,3099],{"style":244},"      credential: ",[214,3101,3102],{"style":240},"JSON",[214,3104,728],{"style":244},[214,3106,3107],{"style":300},"parse",[214,3109,317],{"style":244},[214,3111,3102],{"style":240},[214,3113,728],{"style":244},[214,3115,3116],{"style":300},"stringify",[214,3118,3119],{"style":244},"(authResponse))",[214,3121,3122],{"class":216,"style":217},[214,3123,2955],{"style":244},[214,3125,3126,3129,3132],{"class":216,"style":217},[214,3127,3128],{"style":244},"  } ",[214,3130,3131],{"style":227},"catch",[214,3133,3134],{"style":244}," (err) {",[214,3136,3137],{"class":216,"style":217},[214,3138,3139],{"style":220},"    \u002F\u002F Handle browser-level errors",[214,3141,3142,3144,3147,3150,3152],{"class":216,"style":217},[214,3143,1158],{"style":227},[214,3145,3146],{"style":244}," (err ",[214,3148,3149],{"style":227},"instanceof",[214,3151,2999],{"style":231},[214,3153,3154],{"style":244},") {",[214,3156,3157,3160,3163,3166,3169],{"class":216,"style":217},[214,3158,3159],{"style":227},"      if",[214,3161,3162],{"style":244}," (err.name ",[214,3164,3165],{"style":227},"===",[214,3167,3168],{"style":706}," 'NotAllowedError'",[214,3170,3154],{"style":244},[214,3172,3173],{"class":216,"style":217},[214,3174,3175],{"style":220},"        \u002F\u002F User cancelled the prompt or it timed out",[214,3177,3178,3181,3183],{"class":216,"style":217},[214,3179,3180],{"style":244},"        error.value ",[214,3182,1296],{"style":227},[214,3184,3185],{"style":706}," 'Authentication was cancelled or timed out.'",[214,3187,3188,3191,3194],{"class":216,"style":217},[214,3189,3190],{"style":244},"      } ",[214,3192,3193],{"style":227},"else",[214,3195,1299],{"style":244},[214,3197,3198,3200,3202],{"class":216,"style":217},[214,3199,3180],{"style":244},[214,3201,1296],{"style":227},[214,3203,3204],{"style":244}," err.message",[214,3206,3207],{"class":216,"style":217},[214,3208,2950],{"style":244},[214,3210,3211,3214,3216],{"class":216,"style":217},[214,3212,3213],{"style":244},"    } ",[214,3215,3193],{"style":227},[214,3217,1299],{"style":244},[214,3219,3220,3223,3225],{"class":216,"style":217},[214,3221,3222],{"style":244},"      error.value ",[214,3224,1296],{"style":227},[214,3226,3227],{"style":706}," 'An unexpected error occurred.'",[214,3229,3230],{"class":216,"style":217},[214,3231,1335],{"style":244},[214,3233,3234,3237,3239],{"class":216,"style":217},[214,3235,3236],{"style":244},"    isAuthenticating.value ",[214,3238,1296],{"style":227},[214,3240,1251],{"style":240},[214,3242,3243],{"class":216,"style":217},[214,3244,1556],{"style":244},[214,3246,3247],{"class":216,"style":217},[214,3248,2051],{"style":244},[214,3250],{"class":216,"style":217},[214,3252,3253],{"class":216,"style":217},[214,3254,3255],{"style":220},"\u002F\u002F Allow user to go back to sign-in page",[214,3257,3258],{"class":216,"style":217},[214,3259,3260],{"style":220},"\u002F\u002F This is important - they might realize they're on the wrong account",[214,3262,3263,3266,3269],{"class":216,"style":217},[214,3264,3265],{"style":227},"function",[214,3267,3268],{"style":300}," goBack",[214,3270,2839],{"style":244},[214,3272,3273,3276,3279,3281,3284],{"class":216,"style":217},[214,3274,3275],{"style":244},"  router.",[214,3277,3278],{"style":300},"visit",[214,3280,317],{"style":244},[214,3282,3283],{"style":300},"new_user_session_path",[214,3285,3286],{"style":244},"())",[214,3288,3289],{"class":216,"style":217},[214,3290,2051],{"style":244},[214,3292,3293,3295,3297],{"class":216,"style":217},[214,3294,2790],{"style":244},[214,3296,2538],{"style":2537},[214,3298,2552],{"style":244},[90,3300,3301],{},"The flow is: get challenge, trigger browser UI, send response to server. If authentication succeeds, the server redirects automatically (via Inertia). If it fails, we show an error and let the user retry.",[90,3303,3304],{},"The template:",[205,3306,3307],{"language":2526,"class":208},[210,3308,3309,222,3318,222,3328,222,3343,222,3389,222,3398,222,3400,222,3413,222,3430,222,3457,222,3459,222,3474,222,3479,222,3488,222,3490,222,3495,222,3502,222,3518,222,3528,222,3538,222,3548,222,3558,222,3568,222,3573,222,3575,222,3580,222,3586,222,3599,222,3607,222,3615,222,3631,222,3639,222,3672,222,3693,222,3697,222,3699,222,3704,222,3710,222,3732,222,3748,222,3753,222,3763,222,3777,222,3782,222,3796,222,3826,222,3835,222,3840,222,3848,222,3857,222,3865,222,3874],{"class":2529},[214,3310,3311,3313,3316],{"class":216,"style":217},[214,3312,2534],{"style":244},[214,3314,3315],{"style":2537},"template",[214,3317,2552],{"style":244},[214,3319,3320,3323,3326],{"class":216,"style":217},[214,3321,3322],{"style":244},"  \u003C",[214,3324,3325],{"style":2537},"AuthLayout",[214,3327,2552],{"style":244},[214,3329,3330,3333,3335,3338,3341],{"class":216,"style":217},[214,3331,3332],{"style":244},"    \u003C",[214,3334,3315],{"style":2537},[214,3336,3337],{"style":244}," #",[214,3339,3340],{"style":240},"top-bar",[214,3342,2552],{"style":244},[214,3344,3345,3348,3351,3354,3356,3359,3362,3364,3367,3370,3373,3375,3377,3380,3382,3385,3387],{"class":216,"style":217},[214,3346,3347],{"style":244},"      \u003C",[214,3349,3350],{"style":2537},"UButton",[214,3352,3353],{"style":240}," variant",[214,3355,1296],{"style":244},[214,3357,3358],{"style":706},"\"outline\"",[214,3360,3361],{"style":240}," size",[214,3363,1296],{"style":244},[214,3365,3366],{"style":706},"\"sm\"",[214,3368,3369],{"style":244}," @",[214,3371,3372],{"style":240},"click",[214,3374,1296],{"style":244},[214,3376,2054],{"style":244},[214,3378,3379],{"style":244},"goBack",[214,3381,2054],{"style":244},[214,3383,3384],{"style":244},"> Back to sign in \u003C\u002F",[214,3386,3350],{"style":2537},[214,3388,2552],{"style":244},[214,3390,3391,3394,3396],{"class":216,"style":217},[214,3392,3393],{"style":244},"    \u003C\u002F",[214,3395,3315],{"style":2537},[214,3397,2552],{"style":244},[214,3399],{"class":216,"style":217},[214,3401,3402,3404,3406,3408,3411],{"class":216,"style":217},[214,3403,3332],{"style":244},[214,3405,3315],{"style":2537},[214,3407,3337],{"style":244},[214,3409,3410],{"style":240},"card-content",[214,3412,2552],{"style":244},[214,3414,3415,3417,3420,3423,3425,3428],{"class":216,"style":217},[214,3416,3347],{"style":244},[214,3418,3419],{"style":2537},"div",[214,3421,3422],{"style":240}," class",[214,3424,1296],{"style":244},[214,3426,3427],{"style":706},"\"flex flex-col gap-6\"",[214,3429,2552],{"style":244},[214,3431,3432,3435,3438,3441,3443,3446,3449,3451,3454],{"class":216,"style":217},[214,3433,3434],{"style":244},"        \u003C",[214,3436,3437],{"style":2537},"AuthHeader",[214,3439,3440],{"style":240}," icon",[214,3442,1296],{"style":244},[214,3444,3445],{"style":706},"\"i-hugeicons-finger-print\"",[214,3447,3448],{"style":240}," title",[214,3450,1296],{"style":244},[214,3452,3453],{"style":706},"\"Let's make sure it's you\"",[214,3455,3456],{"style":244}," \u002F>",[214,3458],{"class":216,"style":217},[214,3460,3461,3463,3465,3467,3469,3472],{"class":216,"style":217},[214,3462,3434],{"style":244},[214,3464,90],{"style":2537},[214,3466,3422],{"style":240},[214,3468,1296],{"style":244},[214,3470,3471],{"style":706},"\"text-muted text-center text-sm\"",[214,3473,2552],{"style":244},[214,3475,3476],{"class":216,"style":217},[214,3477,3478],{"style":244},"          Use fingerprint, face, screen lock, or security key to sign in.",[214,3480,3481,3484,3486],{"class":216,"style":217},[214,3482,3483],{"style":244},"        \u003C\u002F",[214,3485,90],{"style":2537},[214,3487,2552],{"style":244},[214,3489],{"class":216,"style":217},[214,3491,3492],{"class":216,"style":217},[214,3493,3494],{"style":220},"        \u003C!-- Browser doesn't support WebAuthn -->",[214,3496,3497,3499],{"class":216,"style":217},[214,3498,3434],{"style":244},[214,3500,3501],{"style":2537},"UAlert",[214,3503,3504,3507,3509,3511,3513,3516],{"class":216,"style":217},[214,3505,3506],{"style":227},"          v-if",[214,3508,1296],{"style":244},[214,3510,2054],{"style":244},[214,3512,2967],{"style":227},[214,3514,3515],{"style":244},"isSupported",[214,3517,2054],{"style":244},[214,3519,3520,3523,3525],{"class":216,"style":217},[214,3521,3522],{"style":240},"          color",[214,3524,1296],{"style":244},[214,3526,3527],{"style":706},"\"error\"",[214,3529,3530,3533,3535],{"class":216,"style":217},[214,3531,3532],{"style":240},"          variant",[214,3534,1296],{"style":244},[214,3536,3537],{"style":706},"\"soft\"",[214,3539,3540,3543,3545],{"class":216,"style":217},[214,3541,3542],{"style":240},"          title",[214,3544,1296],{"style":244},[214,3546,3547],{"style":706},"\"WebAuthn Not Supported\"",[214,3549,3550,3553,3555],{"class":216,"style":217},[214,3551,3552],{"style":240},"          description",[214,3554,1296],{"style":244},[214,3556,3557],{"style":706},"\"Your browser does not support WebAuthn. Please use a modern browser.\"",[214,3559,3560,3563,3565],{"class":216,"style":217},[214,3561,3562],{"style":240},"          icon",[214,3564,1296],{"style":244},[214,3566,3567],{"style":706},"\"i-hugeicons-alert-circle\"",[214,3569,3570],{"class":216,"style":217},[214,3571,3572],{"style":244},"        \u002F>",[214,3574],{"class":216,"style":217},[214,3576,3577],{"class":216,"style":217},[214,3578,3579],{"style":220},"        \u003C!-- Error message with retry option -->",[214,3581,3582,3584],{"class":216,"style":217},[214,3583,3434],{"style":244},[214,3585,3501],{"style":2537},[214,3587,3588,3590,3592,3594,3597],{"class":216,"style":217},[214,3589,3506],{"style":227},[214,3591,1296],{"style":244},[214,3593,2054],{"style":244},[214,3595,3596],{"style":244},"error",[214,3598,2054],{"style":244},[214,3600,3601,3603,3605],{"class":216,"style":217},[214,3602,3522],{"style":240},[214,3604,1296],{"style":244},[214,3606,3527],{"style":706},[214,3608,3609,3611,3613],{"class":216,"style":217},[214,3610,3532],{"style":240},[214,3612,1296],{"style":244},[214,3614,3537],{"style":706},[214,3616,3617,3620,3623,3625,3627,3629],{"class":216,"style":217},[214,3618,3619],{"style":244},"          :",[214,3621,3622],{"style":240},"title",[214,3624,1296],{"style":244},[214,3626,2054],{"style":244},[214,3628,3596],{"style":244},[214,3630,2054],{"style":244},[214,3632,3633,3635,3637],{"class":216,"style":217},[214,3634,3562],{"style":240},[214,3636,1296],{"style":244},[214,3638,3567],{"style":706},[214,3640,3641,3643,3646,3648,3650,3653,3656,3659,3662,3665,3668,3670],{"class":216,"style":217},[214,3642,3619],{"style":244},[214,3644,3645],{"style":240},"close-button",[214,3647,1296],{"style":244},[214,3649,2054],{"style":244},[214,3651,3652],{"style":244},"{ icon: ",[214,3654,3655],{"style":706},"'i-hugeicons-cancel-01'",[214,3657,3658],{"style":244},", color: ",[214,3660,3661],{"style":706},"'error'",[214,3663,3664],{"style":244},", variant: ",[214,3666,3667],{"style":706},"'link'",[214,3669,2390],{"style":244},[214,3671,2054],{"style":244},[214,3673,3674,3677,3680,3682,3684,3687,3689,3691],{"class":216,"style":217},[214,3675,3676],{"style":244},"          @",[214,3678,3679],{"style":240},"close",[214,3681,1296],{"style":244},[214,3683,2054],{"style":244},[214,3685,3686],{"style":244},"error ",[214,3688,1296],{"style":227},[214,3690,2700],{"style":240},[214,3692,2054],{"style":244},[214,3694,3695],{"class":216,"style":217},[214,3696,3572],{"style":244},[214,3698],{"class":216,"style":217},[214,3700,3701],{"class":216,"style":217},[214,3702,3703],{"style":220},"        \u003C!-- Primary action button -->",[214,3705,3706,3708],{"class":216,"style":217},[214,3707,3434],{"style":244},[214,3709,3350],{"style":2537},[214,3711,3712,3714,3717,3719,3721,3723,3726,3728,3730],{"class":216,"style":217},[214,3713,3619],{"style":244},[214,3715,3716],{"style":240},"disabled",[214,3718,1296],{"style":244},[214,3720,2054],{"style":244},[214,3722,2967],{"style":227},[214,3724,3725],{"style":244},"isSupported ",[214,3727,3005],{"style":227},[214,3729,2667],{"style":244},[214,3731,2054],{"style":244},[214,3733,3734,3736,3739,3741,3743,3746],{"class":216,"style":217},[214,3735,3619],{"style":244},[214,3737,3738],{"style":240},"loading",[214,3740,1296],{"style":244},[214,3742,2054],{"style":244},[214,3744,3745],{"style":244},"isAuthenticating",[214,3747,2054],{"style":244},[214,3749,3750],{"class":216,"style":217},[214,3751,3752],{"style":240},"          block",[214,3754,3755,3758,3760],{"class":216,"style":217},[214,3756,3757],{"style":240},"          size",[214,3759,1296],{"style":244},[214,3761,3762],{"style":706},"\"lg\"",[214,3764,3765,3767,3769,3771,3773,3775],{"class":216,"style":217},[214,3766,3676],{"style":244},[214,3768,3372],{"style":240},[214,3770,1296],{"style":244},[214,3772,2054],{"style":244},[214,3774,1237],{"style":244},[214,3776,2054],{"style":244},[214,3778,3779],{"class":216,"style":217},[214,3780,3781],{"style":244},"        >",[214,3783,3784,3787,3789,3791,3794],{"class":216,"style":217},[214,3785,3786],{"style":244},"          \u003C",[214,3788,3315],{"style":2537},[214,3790,3337],{"style":244},[214,3792,3793],{"style":240},"leading",[214,3795,2552],{"style":244},[214,3797,3798,3801,3804,3807,3809,3811,3813,3815,3817,3820,3822,3824],{"class":216,"style":217},[214,3799,3800],{"style":244},"            \u003C",[214,3802,3803],{"style":2537},"UIcon",[214,3805,3806],{"style":227}," v-if",[214,3808,1296],{"style":244},[214,3810,2054],{"style":244},[214,3812,2967],{"style":227},[214,3814,3745],{"style":244},[214,3816,2054],{"style":244},[214,3818,3819],{"style":240}," name",[214,3821,1296],{"style":244},[214,3823,3445],{"style":706},[214,3825,3456],{"style":244},[214,3827,3828,3831,3833],{"class":216,"style":217},[214,3829,3830],{"style":244},"          \u003C\u002F",[214,3832,3315],{"style":2537},[214,3834,2552],{"style":244},[214,3836,3837],{"class":216,"style":217},[214,3838,3839],{"style":244},"          {{ isAuthenticating ? 'Verifying...' : 'Sign in with passkey' }}",[214,3841,3842,3844,3846],{"class":216,"style":217},[214,3843,3483],{"style":244},[214,3845,3350],{"style":2537},[214,3847,2552],{"style":244},[214,3849,3850,3853,3855],{"class":216,"style":217},[214,3851,3852],{"style":244},"      \u003C\u002F",[214,3854,3419],{"style":2537},[214,3856,2552],{"style":244},[214,3858,3859,3861,3863],{"class":216,"style":217},[214,3860,3393],{"style":244},[214,3862,3315],{"style":2537},[214,3864,2552],{"style":244},[214,3866,3867,3870,3872],{"class":216,"style":217},[214,3868,3869],{"style":244},"  \u003C\u002F",[214,3871,3325],{"style":2537},[214,3873,2552],{"style":244},[214,3875,3876,3878,3880],{"class":216,"style":217},[214,3877,2790],{"style":244},[214,3879,3315],{"style":2537},[214,3881,2552],{"style":244},[90,3883,3884],{},"The UI is simple: a title, description, error display, and a big button. If authentication is happening, we show a loading state. If it failed, users can click to retry.",[90,3886,3887,3888,3890],{},"We'll add backup code support to this same page later in ",[124,3889,2522],{"href":151},". For now, this handles the passkey-only flow.",[199,3892,51],{"id":50},[90,3894,3895],{},"Authentication issues to watch for:",[997,3897,3898,3907,3913],{},[1000,3899,3900,3903,3904,3906],{},[133,3901,3902],{},"Session mismatch",": If a user has multiple tabs open and signs in on one, the other tab's 2FA session becomes stale. The ",[210,3905,423],{}," concern checks for this and clears orphaned sessions.",[1000,3908,3909,3912],{},[133,3910,3911],{},"Wrong credential",": Users with multiple passkeys might present the wrong one. The verification will fail because the signature doesn't match the stored public key. This is expected behavior - they just need to try their other passkey.",[1000,3914,3915,3918],{},[133,3916,3917],{},"Browser doesn't support WebAuthn",": Some browsers (especially older mobile browsers) don't support WebAuthn. Check for support before showing passkey options and have a fallback.",[187,3920,54],{"id":53},[90,3922,3923],{},"Password-full works. Now let's add password-less. Users with passkeys should be able to skip the password entirely. This is where passkeys become genuinely better than passwords, not just an extra step.",[90,3925,3926],{},[195,3927],{"src":3928},"\u002Fimages\u002Fblog\u002Frails-passwordless-authentication-webauthn-2fa-2.webp",[199,3930,58],{"id":57},[90,3932,3933],{},"We need a way to check if a user has passkeys before showing them the password form. Add the routes:",[205,3935,3936],{"language":207,"class":208},[210,3937,3938,222,3942,222,3951,222,3964],{"class":212},[214,3939,3940],{"class":216,"style":217},[214,3941,925],{"style":220},[214,3943,3944,3946,3949],{"class":216,"style":217},[214,3945,930],{"style":244},[214,3947,3948],{"style":240},":auth",[214,3950,936],{"style":227},[214,3952,3953,3955,3958,3960,3962],{"class":216,"style":217},[214,3954,948],{"style":244},[214,3956,3957],{"style":240},":lookup",[214,3959,464],{"style":244},[214,3961,467],{"style":240},[214,3963,984],{"style":240},[214,3965,3966],{"class":216,"style":217},[214,3967,375],{"style":227},[90,3969,3970],{},"The controller:",[205,3972,3973],{"language":207,"class":208},[210,3974,3975,222,3980,222,3991,222,3997,222,3999,222,4017,222,4019,222,4025,222,4066,222,4068,222,4073,222,4078,222,4102,222,4106],{"class":212},[214,3976,3977],{"class":216,"style":217},[214,3978,3979],{"style":220},"# app\u002Fcontrollers\u002Fauth\u002Flookups_controller.rb",[214,3981,3982,3984,3987,3989],{"class":216,"style":217},[214,3983,392],{"style":227},[214,3985,3986],{"style":231}," Auth::LookupsController",[214,3988,398],{"style":244},[214,3990,596],{"style":240},[214,3992,3993,3995],{"class":216,"style":217},[214,3994,459],{"style":244},[214,3996,266],{"style":240},[214,3998],{"class":216,"style":217},[214,4000,4001,4003,4005,4007,4009,4011,4013,4015],{"class":216,"style":217},[214,4002,1634],{"style":244},[214,4004,1637],{"style":240},[214,4006,1640],{"style":240},[214,4008,464],{"style":244},[214,4010,1645],{"style":240},[214,4012,1648],{"style":240},[214,4014,728],{"style":244},[214,4016,1653],{"style":300},[214,4018],{"class":216,"style":217},[214,4020,4021,4023],{"class":216,"style":217},[214,4022,297],{"style":227},[214,4024,1138],{"style":300},[214,4026,4027,4029,4031,4034,4036,4038,4040,4043,4046,4049,4051,4054,4056,4059,4061,4064],{"class":216,"style":217},[214,4028,1666],{"style":231},[214,4030,782],{"style":227},[214,4032,4033],{"style":240}," User",[214,4035,728],{"style":244},[214,4037,731],{"style":300},[214,4039,317],{"style":244},[214,4041,4042],{"style":240},"email:",[214,4044,4045],{"style":244}," params[",[214,4047,4048],{"style":240},":email",[214,4050,356],{"style":244},[214,4052,4053],{"style":300},"to_s",[214,4055,728],{"style":244},[214,4057,4058],{"style":300},"strip",[214,4060,728],{"style":244},[214,4062,4063],{"style":300},"downcase",[214,4065,802],{"style":244},[214,4067],{"class":216,"style":217},[214,4069,4070],{"class":216,"style":217},[214,4071,4072],{"style":220},"    # For security, we don't reveal if the user exists or not.",[214,4074,4075],{"class":216,"style":217},[214,4076,4077],{"style":220},"    # We just return whether WebAuthn is available (which requires the user to exist).",[214,4079,4080,4082,4084,4086,4089,4091,4093,4095,4098,4100],{"class":216,"style":217},[214,4081,1119],{"style":244},[214,4083,1691],{"style":240},[214,4085,1694],{"style":244},[214,4087,4088],{"style":240},"web_authn_available:",[214,4090,1680],{"style":244},[214,4092,2316],{"style":227},[214,4094,1187],{"style":300},[214,4096,4097],{"style":227}," ||",[214,4099,1251],{"style":240},[214,4101,2390],{"style":244},[214,4103,4104],{"class":216,"style":217},[214,4105,278],{"style":227},[214,4107,4108],{"class":216,"style":217},[214,4109,375],{"style":227},[90,4111,4112,4113,4115],{},"This is intentionally minimal. The lookup endpoint alone doesn't reveal whether an email exists in our system. It returns ",[210,4114,2676],{}," both when the user doesn't exist and when they exist but have no passkeys.",[90,4117,4118,4121,4122,4124,4125,4127],{},[133,4119,4120],{},"Security note",": While this endpoint is safe in isolation, an attacker could combine it with the sessions endpoint (below) to enumerate users. If lookup returns ",[210,4123,2676],{}," and the sessions endpoint returns 404, the user definitely doesn't exist. If lookup returns ",[210,4126,2676],{}," but sessions redirects, the user exists but has no passkeys. We accept this trade-off for simplicity, but if user enumeration is a concern for your application, you could modify the sessions controller to always redirect (storing an invalid user ID for non-existent users, so the 2FA page shows a generic \"Session expired\" error either way). Rate limiting on both endpoints helps mitigate enumeration attempts.",[199,4129,61],{"id":60},[90,4131,4132],{},"Now we need a way to start the WebAuthn flow without a password. Add another route:",[205,4134,4135],{"language":207,"class":208},[210,4136,4137,222,4141,222,4149,222,4162,222,4167],{"class":212},[214,4138,4139],{"class":216,"style":217},[214,4140,925],{"style":220},[214,4142,4143,4145,4147],{"class":216,"style":217},[214,4144,930],{"style":244},[214,4146,933],{"style":240},[214,4148,936],{"style":227},[214,4150,4151,4153,4156,4158,4160],{"class":216,"style":217},[214,4152,948],{"style":244},[214,4154,4155],{"style":240},":session",[214,4157,464],{"style":244},[214,4159,467],{"style":240},[214,4161,984],{"style":240},[214,4163,4164],{"class":216,"style":217},[214,4165,4166],{"style":220},"  # ... other routes",[214,4168,4169],{"class":216,"style":217},[214,4170,375],{"style":227},[205,4172,4173],{"language":207,"class":208},[210,4174,4175,222,4180,222,4191,222,4197,222,4199,222,4217,222,4219,222,4225,222,4260,222,4262,222,4270,222,4272,222,4288,222,4299,222,4313,222,4317,222,4319,222,4323,222,4327],{"class":212},[214,4176,4177],{"class":216,"style":217},[214,4178,4179],{"style":220},"# app\u002Fcontrollers\u002Fweb_authn\u002Fsessions_controller.rb",[214,4181,4182,4184,4187,4189],{"class":216,"style":217},[214,4183,392],{"style":227},[214,4185,4186],{"style":231}," WebAuthn::SessionsController",[214,4188,398],{"style":244},[214,4190,596],{"style":240},[214,4192,4193,4195],{"class":216,"style":217},[214,4194,459],{"style":244},[214,4196,266],{"style":240},[214,4198],{"class":216,"style":217},[214,4200,4201,4203,4205,4207,4209,4211,4213,4215],{"class":216,"style":217},[214,4202,1634],{"style":244},[214,4204,1637],{"style":240},[214,4206,1640],{"style":240},[214,4208,464],{"style":244},[214,4210,1645],{"style":240},[214,4212,1648],{"style":240},[214,4214,728],{"style":244},[214,4216,1653],{"style":300},[214,4218],{"class":216,"style":217},[214,4220,4221,4223],{"class":216,"style":217},[214,4222,297],{"style":227},[214,4224,1138],{"style":300},[214,4226,4227,4229,4231,4233,4235,4238,4240,4242,4244,4246,4248,4250,4252,4254,4256,4258],{"class":216,"style":217},[214,4228,1666],{"style":231},[214,4230,782],{"style":227},[214,4232,4033],{"style":240},[214,4234,728],{"style":244},[214,4236,4237],{"style":300},"find_by!",[214,4239,317],{"style":244},[214,4241,4042],{"style":240},[214,4243,4045],{"style":244},[214,4245,4048],{"style":240},[214,4247,356],{"style":244},[214,4249,4053],{"style":300},[214,4251,728],{"style":244},[214,4253,4058],{"style":300},[214,4255,728],{"style":244},[214,4257,4063],{"style":300},[214,4259,802],{"style":244},[214,4261],{"class":216,"style":217},[214,4263,4264,4266,4268],{"class":216,"style":217},[214,4265,1273],{"style":244},[214,4267,331],{"style":227},[214,4269,334],{"style":244},[214,4271],{"class":216,"style":217},[214,4273,4274,4276,4278,4280,4282,4284,4286],{"class":216,"style":217},[214,4275,1284],{"style":244},[214,4277,320],{"style":240},[214,4279,245],{"style":244},[214,4281,325],{"style":240},[214,4283,1293],{"style":244},[214,4285,1296],{"style":227},[214,4287,1299],{"style":244},[214,4289,4290,4292,4295,4297],{"class":216,"style":217},[214,4291,1304],{"style":706},[214,4293,4294],{"style":244}," => user.",[214,4296,1310],{"style":300},[214,4298,1313],{"style":244},[214,4300,4301,4303,4305,4307,4309,4311],{"class":216,"style":217},[214,4302,1318],{"style":706},[214,4304,1321],{"style":244},[214,4306,1324],{"style":300},[214,4308,317],{"style":244},[214,4310,830],{"style":240},[214,4312,802],{"style":244},[214,4314,4315],{"class":216,"style":217},[214,4316,1335],{"style":244},[214,4318],{"class":216,"style":217},[214,4320,4321],{"class":216,"style":217},[214,4322,366],{"style":244},[214,4324,4325],{"class":216,"style":217},[214,4326,278],{"style":227},[214,4328,4329],{"class":216,"style":217},[214,4330,375],{"style":227},[90,4332,4333,4334,4336,4337,4340],{},"This controller is intentionally simple. It uses ",[210,4335,4237],{}," which raises ",[210,4338,4339],{},"ActiveRecord::RecordNotFound"," if the user doesn't exist. In normal use, this endpoint is only called after the lookup confirms WebAuthn is available. However, as noted above, an attacker could use the 404 vs redirect difference to enumerate users. We accept this trade-off, relying on rate limiting to slow enumeration attempts.",[90,4342,4343,4344,4346],{},"The controller sets up the pending authentication session and redirects directly to the 2FA page. No JSON response, no checking ",[210,4345,1187],{},". The lookup already did that work. This keeps the controller focused on one thing: starting the password-less flow.",[199,4348,64],{"id":63},[90,4350,4351],{},"Now we modify the sign-in page to check for passkeys after the user enters their email. The page has three steps: method selection (OAuth or email), email entry, and password entry. We add passkey detection between email and password.",[205,4353,4354],{"language":2526,"class":208},[210,4355,4356,222,4372,222,4383,222,4394,222,4405,222,4411,222,4416,222,4421,222,4425,222,4430,222,4438,222,4448,222,4450,222,4455,222,4478,222,4501,222,4503,222,4508,222,4526,222,4543,222,4568,222,4570,222,4575,222,4590,222,4595,222,4604,222,4611,222,4615,222,4619,222,4621,222,4626,222,4647,222,4649,222,4654,222,4671,222,4686,222,4703,222,4718,222,4745,222,4749],{"class":2529},[214,4357,4358,4360,4362,4364,4366,4368,4370],{"class":216,"style":217},[214,4359,2534],{"style":244},[214,4361,2538],{"style":2537},[214,4363,2541],{"style":240},[214,4365,2544],{"style":240},[214,4367,1296],{"style":244},[214,4369,2549],{"style":706},[214,4371,2552],{"style":244},[214,4373,4374,4376,4379,4381],{"class":216,"style":217},[214,4375,2557],{"style":227},[214,4377,4378],{"style":244}," { router, useForm } ",[214,4380,2563],{"style":227},[214,4382,2566],{"style":706},[214,4384,4385,4387,4390,4392],{"class":216,"style":217},[214,4386,2557],{"style":227},[214,4388,4389],{"style":244}," { browserSupportsWebAuthn } ",[214,4391,2563],{"style":227},[214,4393,2578],{"style":706},[214,4395,4396,4398,4401,4403],{"class":216,"style":217},[214,4397,2557],{"style":227},[214,4399,4400],{"style":244}," { ref, computed } ",[214,4402,2563],{"style":227},[214,4404,2590],{"style":706},[214,4406,4407,4409],{"class":216,"style":217},[214,4408,2557],{"style":227},[214,4410,1299],{"style":244},[214,4412,4413],{"class":216,"style":217},[214,4414,4415],{"style":244},"  auth_lookup_path,",[214,4417,4418],{"class":216,"style":217},[214,4419,4420],{"style":244},"  web_authn_session_path,",[214,4422,4423],{"class":216,"style":217},[214,4424,2601],{"style":244},[214,4426,4427],{"class":216,"style":217},[214,4428,4429],{"style":244},"  new_user_password_path",[214,4431,4432,4434,4436],{"class":216,"style":217},[214,4433,2616],{"style":244},[214,4435,2563],{"style":227},[214,4437,2621],{"style":706},[214,4439,4440,4442,4444,4446],{"class":216,"style":217},[214,4441,2557],{"style":227},[214,4443,2628],{"style":244},[214,4445,2563],{"style":227},[214,4447,2633],{"style":706},[214,4449],{"class":216,"style":217},[214,4451,4452],{"class":216,"style":217},[214,4453,4454],{"style":220},"\u002F\u002F Step management: 'method' -> 'email' -> 'password' (or redirect to passkey)",[214,4456,4457,4460,4463,4465,4468,4470,4473,4475],{"class":216,"style":217},[214,4458,4459],{"style":227},"type",[214,4461,4462],{"style":231}," Step",[214,4464,782],{"style":227},[214,4466,4467],{"style":706}," 'method'",[214,4469,2697],{"style":227},[214,4471,4472],{"style":706}," 'email'",[214,4474,2697],{"style":227},[214,4476,4477],{"style":706}," 'password'",[214,4479,4480,4482,4485,4487,4489,4491,4494,4496,4499],{"class":216,"style":217},[214,4481,2645],{"style":227},[214,4483,4484],{"style":240}," step",[214,4486,782],{"style":227},[214,4488,2653],{"style":300},[214,4490,2534],{"style":244},[214,4492,4493],{"style":231},"Step",[214,4495,2703],{"style":244},[214,4497,4498],{"style":706},"'method'",[214,4500,802],{"style":244},[214,4502],{"class":216,"style":217},[214,4504,4505],{"class":216,"style":217},[214,4506,4507],{"style":220},"\u002F\u002F Form state",[214,4509,4510,4512,4515,4517,4519,4521,4524],{"class":216,"style":217},[214,4511,2645],{"style":227},[214,4513,4514],{"style":240}," email",[214,4516,782],{"style":227},[214,4518,2653],{"style":300},[214,4520,317],{"style":244},[214,4522,4523],{"style":706},"''",[214,4525,802],{"style":244},[214,4527,4528,4530,4533,4535,4537,4539,4541],{"class":216,"style":217},[214,4529,2645],{"style":227},[214,4531,4532],{"style":240}," isLookingUp",[214,4534,782],{"style":227},[214,4536,2653],{"style":300},[214,4538,317],{"style":244},[214,4540,2676],{"style":240},[214,4542,802],{"style":244},[214,4544,4545,4547,4550,4552,4554,4556,4558,4560,4562,4564,4566],{"class":216,"style":217},[214,4546,2645],{"style":227},[214,4548,4549],{"style":240}," lookupError",[214,4551,782],{"style":227},[214,4553,2653],{"style":300},[214,4555,2534],{"style":244},[214,4557,2694],{"style":240},[214,4559,2697],{"style":227},[214,4561,2700],{"style":240},[214,4563,2703],{"style":244},[214,4565,2706],{"style":240},[214,4567,802],{"style":244},[214,4569],{"class":216,"style":217},[214,4571,4572],{"class":216,"style":217},[214,4573,4574],{"style":220},"\u002F\u002F Password form for non-WebAuthn users",[214,4576,4577,4579,4582,4584,4587],{"class":216,"style":217},[214,4578,2645],{"style":227},[214,4580,4581],{"style":240}," form",[214,4583,782],{"style":227},[214,4585,4586],{"style":300}," useForm",[214,4588,4589],{"style":244},"({",[214,4591,4592],{"class":216,"style":217},[214,4593,4594],{"style":244},"  user: {",[214,4596,4597,4600,4602],{"class":216,"style":217},[214,4598,4599],{"style":244},"    email: ",[214,4601,4523],{"style":706},[214,4603,1313],{"style":244},[214,4605,4606,4609],{"class":216,"style":217},[214,4607,4608],{"style":244},"    password: ",[214,4610,4523],{"style":706},[214,4612,4613],{"class":216,"style":217},[214,4614,1556],{"style":244},[214,4616,4617],{"class":216,"style":217},[214,4618,2785],{"style":244},[214,4620],{"class":216,"style":217},[214,4622,4623],{"class":216,"style":217},[214,4624,4625],{"style":220},"\u002F\u002F Check browser support once",[214,4627,4628,4630,4633,4635,4638,4641,4643,4645],{"class":216,"style":217},[214,4629,2645],{"style":227},[214,4631,4632],{"style":240}," supportsWebAuthn",[214,4634,782],{"style":227},[214,4636,4637],{"style":300}," computed",[214,4639,4640],{"style":244},"(() ",[214,4642,2731],{"style":227},[214,4644,2743],{"style":300},[214,4646,3286],{"style":244},[214,4648],{"class":216,"style":217},[214,4650,4651],{"class":216,"style":217},[214,4652,4653],{"style":220},"\u002F\u002F Computed: forgot password URL with email pre-filled",[214,4655,4656,4658,4661,4663,4665,4667,4669],{"class":216,"style":217},[214,4657,2645],{"style":227},[214,4659,4660],{"style":240}," forgotPasswordPath",[214,4662,782],{"style":227},[214,4664,4637],{"style":300},[214,4666,4640],{"style":244},[214,4668,2731],{"style":227},[214,4670,1299],{"style":244},[214,4672,4673,4676,4679,4681,4684],{"class":216,"style":217},[214,4674,4675],{"style":227},"  const",[214,4677,4678],{"style":240}," base",[214,4680,782],{"style":227},[214,4682,4683],{"style":300}," new_user_password_path",[214,4685,2746],{"style":244},[214,4687,4688,4690,4693,4695,4698,4701],{"class":216,"style":217},[214,4689,4675],{"style":227},[214,4691,4692],{"style":240}," emailValue",[214,4694,782],{"style":227},[214,4696,4697],{"style":244}," form.user.email.",[214,4699,4700],{"style":300},"trim",[214,4702,2746],{"style":244},[214,4704,4705,4707,4709,4711,4714,4716],{"class":216,"style":217},[214,4706,2763],{"style":227},[214,4708,2964],{"style":244},[214,4710,2967],{"style":227},[214,4712,4713],{"style":244},"emailValue) ",[214,4715,2440],{"style":227},[214,4717,4678],{"style":244},[214,4719,4720,4723,4726,4729,4732,4735,4737,4740,4742],{"class":216,"style":217},[214,4721,4722],{"style":227},"  return",[214,4724,4725],{"style":706}," `${",[214,4727,4728],{"style":244},"base",[214,4730,4731],{"style":706},"}?email=${",[214,4733,4734],{"style":300},"encodeURIComponent",[214,4736,317],{"style":706},[214,4738,4739],{"style":244},"emailValue",[214,4741,802],{"style":706},[214,4743,4744],{"style":706},"}`",[214,4746,4747],{"class":216,"style":217},[214,4748,2785],{"style":244},[214,4750,4751,4753,4755],{"class":216,"style":217},[214,4752,2790],{"style":244},[214,4754,2538],{"style":2537},[214,4756,2552],{"style":244},[90,4758,4759],{},"The step-based approach lets us show different UI based on where the user is in the flow. Now the email continuation handler:",[205,4761,4762],{"language":2526,"class":208},[210,4763,4764,222,4780,222,4784,222,4786,222,4797,222,4815,222,4817,222,4826,222,4835,222,4837,222,4843,222,4848,222,4853,222,4873,222,4881,222,4885,222,4895,222,4905,222,4910,222,4929,222,4933,222,4935,222,4946,222,4961,222,4965,222,4967,222,4984,222,4986,222,4991,222,5005,222,5007,222,5012,222,5019,222,5026,222,5034,222,5039,222,5048,222,5057,222,5061,222,5069,222,5095,222,5104,222,5108,222,5112],{"class":2529},[214,4765,4766,4768,4770,4772,4774,4776,4778],{"class":216,"style":217},[214,4767,2534],{"style":244},[214,4769,2538],{"style":2537},[214,4771,2541],{"style":240},[214,4773,2544],{"style":240},[214,4775,1296],{"style":244},[214,4777,2549],{"style":706},[214,4779,2552],{"style":244},[214,4781,4782],{"class":216,"style":217},[214,4783,2825],{"style":220},[214,4785],{"class":216,"style":217},[214,4787,4788,4790,4792,4795],{"class":216,"style":217},[214,4789,2725],{"style":227},[214,4791,2834],{"style":227},[214,4793,4794],{"style":300}," handleEmailContinue",[214,4796,2839],{"style":244},[214,4798,4799,4801,4803,4805,4808,4810,4813],{"class":216,"style":217},[214,4800,2763],{"style":227},[214,4802,2964],{"style":244},[214,4804,2967],{"style":227},[214,4806,4807],{"style":244},"email.value.",[214,4809,4700],{"style":300},[214,4811,4812],{"style":244},"()) ",[214,4814,2440],{"style":227},[214,4816],{"class":216,"style":217},[214,4818,4819,4822,4824],{"class":216,"style":217},[214,4820,4821],{"style":244},"  isLookingUp.value ",[214,4823,1296],{"style":227},[214,4825,856],{"style":240},[214,4827,4828,4831,4833],{"class":216,"style":217},[214,4829,4830],{"style":244},"  lookupError.value ",[214,4832,1296],{"style":227},[214,4834,2700],{"style":240},[214,4836],{"class":216,"style":217},[214,4838,4839,4841],{"class":216,"style":217},[214,4840,2864],{"style":227},[214,4842,1299],{"style":244},[214,4844,4845],{"class":216,"style":217},[214,4846,4847],{"style":220},"    \u002F\u002F First, check if the user has WebAuthn enabled",[214,4849,4850],{"class":216,"style":217},[214,4851,4852],{"style":220},"    \u002F\u002F This is a lightweight check that doesn't reveal user existence",[214,4854,4855,4857,4860,4862,4864,4866,4868,4871],{"class":216,"style":217},[214,4856,2886],{"style":227},[214,4858,4859],{"style":240}," response",[214,4861,782],{"style":227},[214,4863,2894],{"style":227},[214,4865,2897],{"style":300},[214,4867,317],{"style":244},[214,4869,4870],{"style":300},"auth_lookup_path",[214,4872,2905],{"style":244},[214,4874,4875,4877,4879],{"class":216,"style":217},[214,4876,2910],{"style":244},[214,4878,2913],{"style":706},[214,4880,1313],{"style":244},[214,4882,4883],{"class":216,"style":217},[214,4884,2920],{"style":244},[214,4886,4887,4889,4891,4893],{"class":216,"style":217},[214,4888,2925],{"style":706},[214,4890,2928],{"style":244},[214,4892,2931],{"style":706},[214,4894,1313],{"style":244},[214,4896,4897,4899,4901,4903],{"class":216,"style":217},[214,4898,2938],{"style":706},[214,4900,2928],{"style":244},[214,4902,2943],{"style":300},[214,4904,2746],{"style":244},[214,4906,4907],{"class":216,"style":217},[214,4908,4909],{"style":244},"      },",[214,4911,4912,4915,4917,4919,4921,4924,4926],{"class":216,"style":217},[214,4913,4914],{"style":244},"      body: ",[214,4916,3102],{"style":240},[214,4918,728],{"style":244},[214,4920,3116],{"style":300},[214,4922,4923],{"style":244},"({ email: email.value.",[214,4925,4700],{"style":300},[214,4927,4928],{"style":244},"() })",[214,4930,4931],{"class":216,"style":217},[214,4932,2955],{"style":244},[214,4934],{"class":216,"style":217},[214,4936,4937,4939,4941,4943],{"class":216,"style":217},[214,4938,1158],{"style":227},[214,4940,2964],{"style":244},[214,4942,2967],{"style":227},[214,4944,4945],{"style":244},"response.ok) {",[214,4947,4948,4950,4952,4954,4956,4959],{"class":216,"style":217},[214,4949,1169],{"style":227},[214,4951,1065],{"style":227},[214,4953,2999],{"style":300},[214,4955,317],{"style":244},[214,4957,4958],{"style":706},"'Failed to check authentication method'",[214,4960,802],{"style":244},[214,4962,4963],{"class":216,"style":217},[214,4964,1335],{"style":244},[214,4966],{"class":216,"style":217},[214,4968,4969,4971,4973,4975,4977,4980,4982],{"class":216,"style":217},[214,4970,2886],{"style":227},[214,4972,2978],{"style":240},[214,4974,782],{"style":227},[214,4976,2894],{"style":227},[214,4978,4979],{"style":244}," response.",[214,4981,2988],{"style":300},[214,4983,2746],{"style":244},[214,4985],{"class":216,"style":217},[214,4987,4988],{"class":216,"style":217},[214,4989,4990],{"style":220},"    \u002F\u002F Store email for password form (in case we need it)",[214,4992,4993,4996,4998,5001,5003],{"class":216,"style":217},[214,4994,4995],{"style":244},"    form.user.email ",[214,4997,1296],{"style":227},[214,4999,5000],{"style":244}," email.value.",[214,5002,4700],{"style":300},[214,5004,2746],{"style":244},[214,5006],{"class":216,"style":217},[214,5008,5009],{"class":216,"style":217},[214,5010,5011],{"style":220},"    \u002F\u002F If WebAuthn is available, go directly to verification",[214,5013,5014,5016],{"class":216,"style":217},[214,5015,1158],{"style":227},[214,5017,5018],{"style":244}," (data.web_authn_available) {",[214,5020,5021,5024],{"class":216,"style":217},[214,5022,5023],{"style":300},"      startPasswordlessFlow",[214,5025,2746],{"style":244},[214,5027,5028,5030,5032],{"class":216,"style":217},[214,5029,3213],{"style":244},[214,5031,3193],{"style":227},[214,5033,1299],{"style":244},[214,5035,5036],{"class":216,"style":217},[214,5037,5038],{"style":220},"      \u002F\u002F No WebAuthn - show password form",[214,5040,5041,5044,5046],{"class":216,"style":217},[214,5042,5043],{"style":244},"      step.value ",[214,5045,1296],{"style":227},[214,5047,4477],{"style":706},[214,5049,5050,5053,5055],{"class":216,"style":217},[214,5051,5052],{"style":244},"      isLookingUp.value ",[214,5054,1296],{"style":227},[214,5056,1251],{"style":240},[214,5058,5059],{"class":216,"style":217},[214,5060,1335],{"style":244},[214,5062,5063,5065,5067],{"class":216,"style":217},[214,5064,3128],{"style":244},[214,5066,3131],{"style":227},[214,5068,3134],{"style":244},[214,5070,5071,5074,5076,5079,5081,5083,5086,5089,5092],{"class":216,"style":217},[214,5072,5073],{"style":244},"    lookupError.value ",[214,5075,1296],{"style":227},[214,5077,5078],{"style":244}," err ",[214,5080,3149],{"style":227},[214,5082,2999],{"style":231},[214,5084,5085],{"style":227}," ?",[214,5087,5088],{"style":244}," err.message ",[214,5090,5091],{"style":227},":",[214,5093,5094],{"style":706}," 'An error occurred'",[214,5096,5097,5100,5102],{"class":216,"style":217},[214,5098,5099],{"style":244},"    isLookingUp.value ",[214,5101,1296],{"style":227},[214,5103,1251],{"style":240},[214,5105,5106],{"class":216,"style":217},[214,5107,1556],{"style":244},[214,5109,5110],{"class":216,"style":217},[214,5111,2051],{"style":244},[214,5113,5114,5116,5118],{"class":216,"style":217},[214,5115,2790],{"style":244},[214,5117,2538],{"style":2537},[214,5119,2552],{"style":244},[90,5121,5122],{},"If the user has passkeys enabled, we direct them through the password-less flow. If they don't, we show the password form. If the browser doesn't support WebAuthn, the 2FA page will handle it gracefully and the user can use a backup code to complete authentication.",[90,5124,5125],{},[195,5126],{"src":5127},"\u002Fimages\u002Fblog\u002Frails-passwordless-authentication-webauthn-2fa-3.webp",[90,5129,5130],{},"The password-less flow initiation:",[205,5132,5133],{"language":2526,"class":208},[210,5134,5135,222,5151,222,5155,222,5157,222,5166,222,5180,222,5184],{"class":2529},[214,5136,5137,5139,5141,5143,5145,5147,5149],{"class":216,"style":217},[214,5138,2534],{"style":244},[214,5140,2538],{"style":2537},[214,5142,2541],{"style":240},[214,5144,2544],{"style":240},[214,5146,1296],{"style":244},[214,5148,2549],{"style":706},[214,5150,2552],{"style":244},[214,5152,5153],{"class":216,"style":217},[214,5154,2825],{"style":220},[214,5156],{"class":216,"style":217},[214,5158,5159,5161,5164],{"class":216,"style":217},[214,5160,3265],{"style":227},[214,5162,5163],{"style":300}," startPasswordlessFlow",[214,5165,2839],{"style":244},[214,5167,5168,5170,5172,5174,5177],{"class":216,"style":217},[214,5169,3275],{"style":244},[214,5171,3087],{"style":300},[214,5173,317],{"style":244},[214,5175,5176],{"style":300},"web_authn_session_path",[214,5178,5179],{"style":244},"(), { email: form.user.email })",[214,5181,5182],{"class":216,"style":217},[214,5183,2051],{"style":244},[214,5185,5186,5188,5190],{"class":216,"style":217},[214,5187,2790],{"style":244},[214,5189,2538],{"style":2537},[214,5191,2552],{"style":244},[90,5193,5194,5195,5198],{},"We use Inertia's ",[210,5196,5197],{},"router.post()"," because the sessions controller redirects directly. Inertia handles the redirect automatically and navigates for us. Clean and simple.",[90,5200,5201],{},"The rest of the component handles navigation between steps and the password form:",[205,5203,5204],{"language":2526,"class":208},[210,5205,5206,222,5222,222,5226,222,5228,222,5233,222,5241,222,5254,222,5263,222,5271,222,5279,222,5287,222,5295,222,5305,222,5313,222,5321,222,5325,222,5329,222,5331,222,5336,222,5345,222,5354,222,5358,222,5360,222,5365,222,5374,222,5387,222,5399,222,5408,222,5412,222,5417,222,5421],{"class":2529},[214,5207,5208,5210,5212,5214,5216,5218,5220],{"class":216,"style":217},[214,5209,2534],{"style":244},[214,5211,2538],{"style":2537},[214,5213,2541],{"style":240},[214,5215,2544],{"style":240},[214,5217,1296],{"style":244},[214,5219,2549],{"style":706},[214,5221,2552],{"style":244},[214,5223,5224],{"class":216,"style":217},[214,5225,2825],{"style":220},[214,5227],{"class":216,"style":217},[214,5229,5230],{"class":216,"style":217},[214,5231,5232],{"style":220},"\u002F\u002F Navigate back through steps",[214,5234,5235,5237,5239],{"class":216,"style":217},[214,5236,3265],{"style":227},[214,5238,3268],{"style":300},[214,5240,2839],{"style":244},[214,5242,5243,5245,5248,5250,5252],{"class":216,"style":217},[214,5244,2763],{"style":227},[214,5246,5247],{"style":244}," (step.value ",[214,5249,3165],{"style":227},[214,5251,4477],{"style":706},[214,5253,3154],{"style":244},[214,5255,5256,5259,5261],{"class":216,"style":217},[214,5257,5258],{"style":244},"    step.value ",[214,5260,1296],{"style":227},[214,5262,4472],{"style":706},[214,5264,5265,5267,5269],{"class":216,"style":217},[214,5266,5073],{"style":244},[214,5268,1296],{"style":227},[214,5270,2700],{"style":240},[214,5272,5273,5275,5277],{"class":216,"style":217},[214,5274,5099],{"style":244},[214,5276,1296],{"style":227},[214,5278,1251],{"style":240},[214,5280,5281,5283,5285],{"class":216,"style":217},[214,5282,3128],{"style":244},[214,5284,3193],{"style":227},[214,5286,1299],{"style":244},[214,5288,5289,5291,5293],{"class":216,"style":217},[214,5290,5258],{"style":244},[214,5292,1296],{"style":227},[214,5294,4467],{"style":706},[214,5296,5297,5300,5302],{"class":216,"style":217},[214,5298,5299],{"style":244},"    email.value ",[214,5301,1296],{"style":227},[214,5303,5304],{"style":706}," ''",[214,5306,5307,5309,5311],{"class":216,"style":217},[214,5308,5073],{"style":244},[214,5310,1296],{"style":227},[214,5312,2700],{"style":240},[214,5314,5315,5317,5319],{"class":216,"style":217},[214,5316,5099],{"style":244},[214,5318,1296],{"style":227},[214,5320,1251],{"style":240},[214,5322,5323],{"class":216,"style":217},[214,5324,1556],{"style":244},[214,5326,5327],{"class":216,"style":217},[214,5328,2051],{"style":244},[214,5330],{"class":216,"style":217},[214,5332,5333],{"class":216,"style":217},[214,5334,5335],{"style":220},"\u002F\u002F Start email flow from method selection",[214,5337,5338,5340,5343],{"class":216,"style":217},[214,5339,3265],{"style":227},[214,5341,5342],{"style":300}," startEmailFlow",[214,5344,2839],{"style":244},[214,5346,5347,5350,5352],{"class":216,"style":217},[214,5348,5349],{"style":244},"  step.value ",[214,5351,1296],{"style":227},[214,5353,4472],{"style":706},[214,5355,5356],{"class":216,"style":217},[214,5357,2051],{"style":244},[214,5359],{"class":216,"style":217},[214,5361,5362],{"class":216,"style":217},[214,5363,5364],{"style":220},"\u002F\u002F Submit password form",[214,5366,5367,5369,5372],{"class":216,"style":217},[214,5368,3265],{"style":227},[214,5370,5371],{"style":300}," handlePasswordSubmit",[214,5373,2839],{"style":244},[214,5375,5376,5379,5381,5383,5385],{"class":216,"style":217},[214,5377,5378],{"style":244},"  form.",[214,5380,3087],{"style":300},[214,5382,317],{"style":244},[214,5384,3283],{"style":300},[214,5386,2905],{"style":244},[214,5388,5389,5392,5395,5397],{"class":216,"style":217},[214,5390,5391],{"style":300},"    onFinish",[214,5393,5394],{"style":244},": () ",[214,5396,2731],{"style":227},[214,5398,1299],{"style":244},[214,5400,5401,5404,5406],{"class":216,"style":217},[214,5402,5403],{"style":244},"      form.user.password ",[214,5405,1296],{"style":227},[214,5407,5304],{"style":706},[214,5409,5410],{"class":216,"style":217},[214,5411,1335],{"style":244},[214,5413,5414],{"class":216,"style":217},[214,5415,5416],{"style":244},"  })",[214,5418,5419],{"class":216,"style":217},[214,5420,2051],{"style":244},[214,5422,5423,5425,5427],{"class":216,"style":217},[214,5424,2790],{"style":244},[214,5426,2538],{"style":2537},[214,5428,2552],{"style":244},[90,5430,5431],{},"The template uses transitions between steps for a polished feel:",[205,5433,5434],{"language":2526,"class":208},[210,5435,5436,222,5444,222,5452,222,5464,222,5488,222,5493,222,5516,222,5521,222,5529,222,5531,222,5536,222,5559,222,5576,222,5618,222,5645,222,5650,222,5659,222,5667,222,5675,222,5677,222,5682,222,5704,222,5719,222,5744,222,5776,222,5784,222,5818,222,5826,222,5834,222,5842,222,5850],{"class":2529},[214,5437,5438,5440,5442],{"class":216,"style":217},[214,5439,2534],{"style":244},[214,5441,3315],{"style":2537},[214,5443,2552],{"style":244},[214,5445,5446,5448,5450],{"class":216,"style":217},[214,5447,3322],{"style":244},[214,5449,3325],{"style":2537},[214,5451,2552],{"style":244},[214,5453,5454,5456,5458,5460,5462],{"class":216,"style":217},[214,5455,3332],{"style":244},[214,5457,3315],{"style":2537},[214,5459,3337],{"style":244},[214,5461,3410],{"style":240},[214,5463,2552],{"style":244},[214,5465,5466,5468,5471,5473,5475,5478,5481,5483,5486],{"class":216,"style":217},[214,5467,3347],{"style":244},[214,5469,5470],{"style":2537},"Transition",[214,5472,3819],{"style":240},[214,5474,1296],{"style":244},[214,5476,5477],{"style":706},"\"fade\"",[214,5479,5480],{"style":240}," mode",[214,5482,1296],{"style":244},[214,5484,5485],{"style":706},"\"out-in\"",[214,5487,2552],{"style":244},[214,5489,5490],{"class":216,"style":217},[214,5491,5492],{"style":220},"        \u003C!-- Step 1: Method selection -->",[214,5494,5495,5497,5499,5501,5503,5506,5509,5511,5514],{"class":216,"style":217},[214,5496,3434],{"style":244},[214,5498,3419],{"style":2537},[214,5500,3806],{"style":240},[214,5502,1296],{"style":244},[214,5504,5505],{"style":706},"\"step === 'method'\"",[214,5507,5508],{"style":240}," key",[214,5510,1296],{"style":244},[214,5512,5513],{"style":706},"\"method\"",[214,5515,2552],{"style":244},[214,5517,5518],{"class":216,"style":217},[214,5519,5520],{"style":220},"          \u003C!-- OAuth buttons, email button -->",[214,5522,5523,5525,5527],{"class":216,"style":217},[214,5524,3483],{"style":244},[214,5526,3419],{"style":2537},[214,5528,2552],{"style":244},[214,5530],{"class":216,"style":217},[214,5532,5533],{"class":216,"style":217},[214,5534,5535],{"style":220},"        \u003C!-- Step 2: Email input -->",[214,5537,5538,5540,5542,5545,5547,5550,5552,5554,5557],{"class":216,"style":217},[214,5539,3434],{"style":244},[214,5541,3419],{"style":2537},[214,5543,5544],{"style":240}," v-else-if",[214,5546,1296],{"style":244},[214,5548,5549],{"style":706},"\"step === 'email'\"",[214,5551,5508],{"style":240},[214,5553,1296],{"style":244},[214,5555,5556],{"style":706},"\"email\"",[214,5558,2552],{"style":244},[214,5560,5561,5563,5566,5569,5571,5574],{"class":216,"style":217},[214,5562,3786],{"style":244},[214,5564,5565],{"style":2537},"form",[214,5567,5568],{"style":240}," @submit.prevent",[214,5570,1296],{"style":244},[214,5572,5573],{"style":706},"\"handleEmailContinue\"",[214,5575,2552],{"style":244},[214,5577,5578,5580,5583,5586,5588,5590,5593,5595,5598,5600,5602,5605,5607,5609,5611,5614,5616],{"class":216,"style":217},[214,5579,3800],{"style":244},[214,5581,5582],{"style":2537},"UInput",[214,5584,5585],{"style":240}," v-model",[214,5587,1296],{"style":244},[214,5589,2054],{"style":244},[214,5591,5592],{"style":244},"email",[214,5594,2054],{"style":244},[214,5596,5597],{"style":240}," type",[214,5599,1296],{"style":244},[214,5601,5556],{"style":706},[214,5603,5604],{"style":244}," :",[214,5606,3716],{"style":240},[214,5608,1296],{"style":244},[214,5610,2054],{"style":244},[214,5612,5613],{"style":244},"isLookingUp",[214,5615,2054],{"style":244},[214,5617,3456],{"style":244},[214,5619,5620,5622,5624,5626,5628,5631,5633,5635,5637,5639,5641,5643],{"class":216,"style":217},[214,5621,3800],{"style":244},[214,5623,3350],{"style":2537},[214,5625,5597],{"style":240},[214,5627,1296],{"style":244},[214,5629,5630],{"style":706},"\"submit\"",[214,5632,5604],{"style":244},[214,5634,3738],{"style":240},[214,5636,1296],{"style":244},[214,5638,2054],{"style":244},[214,5640,5613],{"style":244},[214,5642,2054],{"style":244},[214,5644,2552],{"style":244},[214,5646,5647],{"class":216,"style":217},[214,5648,5649],{"style":244},"              {{ isLookingUp ? 'Checking...' : 'Continue' }}",[214,5651,5652,5655,5657],{"class":216,"style":217},[214,5653,5654],{"style":244},"            \u003C\u002F",[214,5656,3350],{"style":2537},[214,5658,2552],{"style":244},[214,5660,5661,5663,5665],{"class":216,"style":217},[214,5662,3830],{"style":244},[214,5664,5565],{"style":2537},[214,5666,2552],{"style":244},[214,5668,5669,5671,5673],{"class":216,"style":217},[214,5670,3483],{"style":244},[214,5672,3419],{"style":2537},[214,5674,2552],{"style":244},[214,5676],{"class":216,"style":217},[214,5678,5679],{"class":216,"style":217},[214,5680,5681],{"style":220},"        \u003C!-- Step 3: Password input (only for users without passkeys) -->",[214,5683,5684,5686,5688,5690,5692,5695,5697,5699,5702],{"class":216,"style":217},[214,5685,3434],{"style":244},[214,5687,3419],{"style":2537},[214,5689,5544],{"style":240},[214,5691,1296],{"style":244},[214,5693,5694],{"style":706},"\"step === 'password'\"",[214,5696,5508],{"style":240},[214,5698,1296],{"style":244},[214,5700,5701],{"style":706},"\"password\"",[214,5703,2552],{"style":244},[214,5705,5706,5708,5710,5712,5714,5717],{"class":216,"style":217},[214,5707,3786],{"style":244},[214,5709,5565],{"style":2537},[214,5711,5568],{"style":240},[214,5713,1296],{"style":244},[214,5715,5716],{"style":706},"\"handlePasswordSubmit\"",[214,5718,2552],{"style":244},[214,5720,5721,5723,5725,5727,5729,5731,5734,5736,5738,5740,5742],{"class":216,"style":217},[214,5722,3800],{"style":244},[214,5724,5582],{"style":2537},[214,5726,5585],{"style":240},[214,5728,1296],{"style":244},[214,5730,2054],{"style":244},[214,5732,5733],{"style":244},"form.user.password",[214,5735,2054],{"style":244},[214,5737,5597],{"style":240},[214,5739,1296],{"style":244},[214,5741,5701],{"style":706},[214,5743,3456],{"style":244},[214,5745,5746,5748,5750,5752,5754,5756,5758,5760,5762,5764,5767,5769,5772,5774],{"class":216,"style":217},[214,5747,3800],{"style":244},[214,5749,3350],{"style":2537},[214,5751,5597],{"style":240},[214,5753,1296],{"style":244},[214,5755,5630],{"style":706},[214,5757,5604],{"style":244},[214,5759,3738],{"style":240},[214,5761,1296],{"style":244},[214,5763,2054],{"style":244},[214,5765,5766],{"style":244},"form.processing",[214,5768,2054],{"style":244},[214,5770,5771],{"style":244},">Sign in\u003C\u002F",[214,5773,3350],{"style":2537},[214,5775,2552],{"style":244},[214,5777,5778,5780,5782],{"class":216,"style":217},[214,5779,3830],{"style":244},[214,5781,5565],{"style":2537},[214,5783,2552],{"style":244},[214,5785,5786,5788,5790,5792,5794,5797,5799,5802,5804,5806,5809,5811,5814,5816],{"class":216,"style":217},[214,5787,3786],{"style":244},[214,5789,3350],{"style":2537},[214,5791,3353],{"style":240},[214,5793,1296],{"style":244},[214,5795,5796],{"style":706},"\"link\"",[214,5798,5604],{"style":244},[214,5800,5801],{"style":240},"to",[214,5803,1296],{"style":244},[214,5805,2054],{"style":244},[214,5807,5808],{"style":244},"forgotPasswordPath",[214,5810,2054],{"style":244},[214,5812,5813],{"style":244},">Forgot password?\u003C\u002F",[214,5815,3350],{"style":2537},[214,5817,2552],{"style":244},[214,5819,5820,5822,5824],{"class":216,"style":217},[214,5821,3483],{"style":244},[214,5823,3419],{"style":2537},[214,5825,2552],{"style":244},[214,5827,5828,5830,5832],{"class":216,"style":217},[214,5829,3852],{"style":244},[214,5831,5470],{"style":2537},[214,5833,2552],{"style":244},[214,5835,5836,5838,5840],{"class":216,"style":217},[214,5837,3393],{"style":244},[214,5839,3315],{"style":2537},[214,5841,2552],{"style":244},[214,5843,5844,5846,5848],{"class":216,"style":217},[214,5845,3869],{"style":244},[214,5847,3325],{"style":2537},[214,5849,2552],{"style":244},[214,5851,5852,5854,5856],{"class":216,"style":217},[214,5853,2790],{"style":244},[214,5855,3315],{"style":2537},[214,5857,2552],{"style":244},[199,5859,51],{"id":66},[90,5861,5862],{},"Password-less introduces new failure modes:",[997,5864,5865,5871],{},[1000,5866,5867,5870],{},[133,5868,5869],{},"Email enumeration",": The lookup endpoint reveals whether an email has passkeys. We accept this trade-off for UX, but you could add rate limiting or CAPTCHAs if concerned.",[1000,5872,5873,5876,5877,5879],{},[133,5874,5875],{},"Passkey authentication fails",": The browser doesn't support WebAuthn, the passkey isn't synced to this device, or user verification fails (no biometrics\u002FPIN configured). The 2FA page shows an error; backup codes provide a fallback (see ",[124,5878,2522],{"href":151},").",[187,5881,69],{"id":68},[90,5883,5884],{},"With password-less working, we can simplify. Users with passkeys now go directly to passkey authentication - they never enter a password. The password-full 2FA flow from earlier in this post is no longer needed.",[90,5886,5887,5888,5091],{},"First, simplify the Authentication concern by removing ",[210,5889,423],{},[205,5891,5892],{"language":207,"class":208},[210,5893,5894,222,5898,222,5904,222,5914,222,5916,222,5922,222,5928,222,5932],{"class":212},[214,5895,5896],{"class":216,"style":217},[214,5897,221],{"style":220},[214,5899,5900,5902],{"class":216,"style":217},[214,5901,228],{"style":227},[214,5903,232],{"style":231},[214,5905,5906,5908,5910,5912],{"class":216,"style":217},[214,5907,237],{"style":227},[214,5909,241],{"style":240},[214,5911,245],{"style":244},[214,5913,248],{"style":240},[214,5915],{"class":216,"style":217},[214,5917,5918,5920],{"class":216,"style":217},[214,5919,255],{"style":244},[214,5921,258],{"style":227},[214,5923,5924,5926],{"class":216,"style":217},[214,5925,263],{"style":244},[214,5927,266],{"style":240},[214,5929,5930],{"class":216,"style":217},[214,5931,278],{"style":227},[214,5933,5934],{"class":216,"style":217},[214,5935,375],{"style":227},[90,5937,5938,5939,5941],{},"That's it. No more ",[210,5940,423],{},". Users with passkeys use the password-less flow, so we don't need to intercept requests and redirect them to 2FA.",[90,5943,5944,5945,5947,5948,5951],{},"With ",[210,5946,423],{}," gone, the controllers that were skipping it no longer need those ",[210,5949,5950],{},"skip_before_action"," lines. Update the Sessions controller from earlier to remove it:",[205,5953,5954],{"language":207,"class":208},[210,5955,5956,222,5960,222,5970,222,5975,222,5977,222,5982],{"class":212},[214,5957,5958],{"class":216,"style":217},[214,5959,1034],{"style":220},[214,5961,5962,5964,5966,5968],{"class":216,"style":217},[214,5963,392],{"style":227},[214,5965,449],{"style":231},[214,5967,398],{"style":244},[214,5969,454],{"style":240},[214,5971,5972],{"class":216,"style":217},[214,5973,5974],{"style":220},"  # Remove: skip_before_action :enforce_web_authn_verification, only: %i[new create destroy]",[214,5976],{"class":216,"style":217},[214,5978,5979],{"class":216,"style":217},[214,5980,5981],{"style":220},"  # ... rest of the controller stays the same",[214,5983,5984],{"class":216,"style":217},[214,5985,375],{"style":227},[90,5987,5988,5989,464,5992,5995,5996,728],{},"The same applies to ",[210,5990,5991],{},"ChallengesController",[210,5993,5994],{},"AuthenticationsController",", and any other controllers that were skipping ",[210,5997,423],{},[90,5999,6000,6003,6004,6007,6008,6010],{},[133,6001,6002],{},"Why we still redirect to 2FA",": You might wonder why we redirect WebAuthn users to the 2FA page instead of rejecting their password login. This is important for ",[133,6005,6006],{},"backup code access"," (which we'll implement in ",[124,6009,2522],{"href":151},"). If we rejected password login entirely, users on browsers that don't support WebAuthn (or users who don't have their passkey synced to the current device) would be completely locked out. By allowing password login to proceed to the 2FA page, they can use a backup code as a fallback.",[199,6012,73],{"id":72},[90,6014,6015,6016,6018,6019,6022],{},"With password-full 2FA, we used ",[210,6017,1836],{}," because the password already proved the user's identity. For password-less, the passkey is the ",[133,6020,6021],{},"only"," authentication factor. We need to strengthen our settings.",[90,6024,6025],{},"Update the options controller to require user verification:",[205,6027,6028],{"language":207,"class":208},[210,6029,6030,222,6035,222,6057,222,6064,222,6077,222,6088,222,6097,222,6102,222,6121,222,6128,222,6137,222,6145,222,6149],{"class":212},[214,6031,6032],{"class":216,"style":217},[214,6033,6034],{"style":220},"# app\u002Fcontrollers\u002Fweb_authn\u002Fcredentials\u002Foptions_controller.rb",[214,6036,6037,6040,6042,6044,6046,6048,6050,6052,6055],{"class":216,"style":217},[214,6038,6039],{"style":231},"options",[214,6041,782],{"style":227},[214,6043,1725],{"style":244},[214,6045,320],{"style":240},[214,6047,245],{"style":244},[214,6049,1732],{"style":240},[214,6051,728],{"style":244},[214,6053,6054],{"style":300},"options_for_create",[214,6056,317],{"style":244},[214,6058,6059,6062],{"class":216,"style":217},[214,6060,6061],{"style":240},"  user:",[214,6063,1299],{"style":244},[214,6065,6066,6069,6072,6075],{"class":216,"style":217},[214,6067,6068],{"style":240},"    id:",[214,6070,6071],{"style":244}," current_user.",[214,6073,6074],{"style":300},"web_authn_id",[214,6076,1313],{"style":244},[214,6078,6079,6082,6084,6086],{"class":216,"style":217},[214,6080,6081],{"style":240},"    name:",[214,6083,6071],{"style":244},[214,6085,5592],{"style":300},[214,6087,1313],{"style":244},[214,6089,6090,6093,6095],{"class":216,"style":217},[214,6091,6092],{"style":240},"    display_name:",[214,6094,6071],{"style":244},[214,6096,5592],{"style":300},[214,6098,6099],{"class":216,"style":217},[214,6100,6101],{"style":244},"  },",[214,6103,6104,6107,6109,6111,6113,6115,6117,6119],{"class":216,"style":217},[214,6105,6106],{"style":240},"  exclude:",[214,6108,6071],{"style":244},[214,6110,1750],{"style":300},[214,6112,728],{"style":244},[214,6114,1755],{"style":300},[214,6116,317],{"style":244},[214,6118,1760],{"style":240},[214,6120,1763],{"style":244},[214,6122,6123,6126],{"class":216,"style":217},[214,6124,6125],{"style":240},"  authenticator_selection:",[214,6127,1299],{"style":244},[214,6129,6130,6133,6135],{"class":216,"style":217},[214,6131,6132],{"style":240},"    resident_key:",[214,6134,1771],{"style":706},[214,6136,1313],{"style":244},[214,6138,6139,6142],{"class":216,"style":217},[214,6140,6141],{"style":240},"    user_verification:",[214,6143,6144],{"style":706}," 'required'",[214,6146,6147],{"class":216,"style":217},[214,6148,1556],{"style":244},[214,6150,6151],{"class":216,"style":217},[214,6152,802],{"style":244},[90,6154,6155],{},"And update the challenge controller:",[205,6157,6158],{"language":207,"class":208},[210,6159,6160,222,6164,222,6184,222,6203,222,6210],{"class":212},[214,6161,6162],{"class":216,"style":217},[214,6163,1590],{"style":220},[214,6165,6166,6168,6170,6172,6174,6176,6178,6180,6182],{"class":216,"style":217},[214,6167,6039],{"style":231},[214,6169,782],{"style":227},[214,6171,1725],{"style":244},[214,6173,320],{"style":240},[214,6175,245],{"style":244},[214,6177,1732],{"style":240},[214,6179,728],{"style":244},[214,6181,1737],{"style":300},[214,6183,317],{"style":244},[214,6185,6186,6189,6191,6193,6195,6197,6199,6201],{"class":216,"style":217},[214,6187,6188],{"style":240},"  allow:",[214,6190,1747],{"style":244},[214,6192,1750],{"style":300},[214,6194,728],{"style":244},[214,6196,1755],{"style":300},[214,6198,317],{"style":244},[214,6200,1760],{"style":240},[214,6202,1763],{"style":244},[214,6204,6205,6208],{"class":216,"style":217},[214,6206,6207],{"style":240},"  user_verification:",[214,6209,6144],{"style":706},[214,6211,6212],{"class":216,"style":217},[214,6213,802],{"style":244},[90,6215,6216,6219,6220,6223],{},[133,6217,6218],{},"Why this matters",": With ",[210,6221,6222],{},"user_verification: 'required'",", the authenticator must verify the user's identity (PIN, fingerprint, face) before signing the challenge. This ensures two factors:",[2474,6225,6226,6232],{},[1000,6227,6228,6231],{},[133,6229,6230],{},"Something you have",": The security key or device",[1000,6233,6234,6237],{},[133,6235,6236],{},"Something you know\u002Fare",": PIN or biometric",[90,6239,6240,6241,6243],{},"Without this, if someone steals a user's security key, they could log in with just a touch. With ",[210,6242,6222],{},", they'd also need the PIN or the user's fingerprint.",[90,6245,6246,6249,6250,6253,6254,6257],{},[133,6247,6248],{},"Trade-off",": This excludes older security keys that don't support user verification (PIN-less keys). If you need to support those, use ",[210,6251,6252],{},"'preferred'"," instead of ",[210,6255,6256],{},"'required'",". The authenticator will verify if it can, but won't fail if it can't.",[187,6259,76],{"id":75},[205,6261,6262],{"language":207,"class":208},[210,6263,6264,222,6268,222,6276,222,6288,222,6292,222,6294,222,6302,222,6314,222,6316,222,6324,222,6336,222,6340,222,6342,222,6354],{"class":212},[214,6265,6266],{"class":216,"style":217},[214,6267,925],{"style":220},[214,6269,6270,6272,6274],{"class":216,"style":217},[214,6271,930],{"style":244},[214,6273,3948],{"style":240},[214,6275,936],{"style":227},[214,6277,6278,6280,6282,6284,6286],{"class":216,"style":217},[214,6279,948],{"style":244},[214,6281,3957],{"style":240},[214,6283,464],{"style":244},[214,6285,467],{"style":240},[214,6287,984],{"style":240},[214,6289,6290],{"class":216,"style":217},[214,6291,375],{"style":227},[214,6293],{"class":216,"style":217},[214,6295,6296,6298,6300],{"class":216,"style":217},[214,6297,930],{"style":244},[214,6299,933],{"style":240},[214,6301,936],{"style":227},[214,6303,6304,6306,6308,6310,6312],{"class":216,"style":217},[214,6305,948],{"style":244},[214,6307,4155],{"style":240},[214,6309,464],{"style":244},[214,6311,467],{"style":240},[214,6313,984],{"style":240},[214,6315],{"class":216,"style":217},[214,6317,6318,6320,6322],{"class":216,"style":217},[214,6319,964],{"style":244},[214,6321,967],{"style":240},[214,6323,936],{"style":227},[214,6325,6326,6328,6330,6332,6334],{"class":216,"style":217},[214,6327,974],{"style":244},[214,6329,977],{"style":240},[214,6331,464],{"style":244},[214,6333,467],{"style":240},[214,6335,984],{"style":240},[214,6337,6338],{"class":216,"style":217},[214,6339,278],{"style":227},[214,6341],{"class":216,"style":217},[214,6343,6344,6346,6348,6350,6352],{"class":216,"style":217},[214,6345,948],{"style":244},[214,6347,951],{"style":240},[214,6349,464],{"style":244},[214,6351,467],{"style":240},[214,6353,501],{"style":240},[214,6355,6356],{"class":216,"style":217},[214,6357,375],{"style":227},[90,6359,6360],{},"This gives you:",[997,6362,6363,6369,6375,6380,6385],{},[1000,6364,6365,6368],{},[210,6366,6367],{},"POST \u002Fauth\u002Flookup"," - Check if user has passkeys (password-less flow)",[1000,6370,6371,6374],{},[210,6372,6373],{},"POST \u002Fweb_authn\u002Fsession"," - Start password-less authentication",[1000,6376,6377,6379],{},[210,6378,1004],{}," - 2FA page",[1000,6381,6382,6384],{},[210,6383,1010],{}," - Get authentication challenge",[1000,6386,6387,6389],{},[210,6388,1016],{}," - Verify passkey",[187,6391,79],{"id":78},[90,6393,6394],{},"At this point, users can:",[997,6396,6397,6400,6403],{},[1000,6398,6399],{},"Add passkeys to their accounts",[1000,6401,6402],{},"Sign in with passkeys (password-less)",[1000,6404,6405],{},"Fall back to passwords if they don't have passkeys",[90,6407,6408,6409,6411],{},"But what happens if a user loses their phone or hardware key? They're locked out. In ",[124,6410,2522],{"href":151},", we'll add backup codes - single-use recovery codes that let users regain access when they can't use their passkey.",[90,6413,6414,6417],{},[93,6415,6416],{},"Previous:",[124,6418,6419],{"href":126},[93,6420,6421],{},"Part 1 - Setup and Registration",[90,6423,6424,6427],{},[93,6425,6426],{},"Next:",[124,6428,6429],{"href":151},[93,6430,6431],{},"Part 3 - Backup Codes: The Safety Net",1795351917800]