Remove default add_module for passkey strategy
#48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
Remove the default call to
Devise.add_modulefor the:passkey_authenticatablestrategy.Reasoning
The default call adds
no_input: truefor the strategy which effectively bypassessign_in, as well asafter_actioncontroller filters.Details
With
no_input: trueenabled for the passkey devise strategy it will be considered when checking for already-authenticated sessions inDeviseController::require_no_authentication.When submitting valid passkey credentials to
Sessions#create,require_no_authenticationruns before the action and tries to authenticate against all of the strategies flagged withno_input. If it finds one, it halts, devise adds an already logged in flash message, and redirects to theafter_sign_in_path_for(resource), instead of going through the session create action.This bypasses any user-created
after_actionfilters, and more importantly, thesign_inmethod, both of which may be important for rails apps.The
no_inputoption can't be changed in userland without manually altering devise constants, because the defaultDevise.add_modulehere:devise-passkeys/lib/devise/passkeys.rb
Lines 48 to 51 in 9a57c20
Devise::NO_INPUTconstant and a couple of others.Since the readme currently calls out needing to call
Devise.add_modulemanually during setup, I've just removed the offendingadd_moduleand changed the readme recommendation to not includeno_input.Tests
Tests pass using
warden-webauthn = 0.2.1, but0.3.0adds a new default value (resident_key: required) that affects some tests.