Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Allow to bypass otp_required_for_login: true on certain circumstances #165

Open
fydelio opened this issue Feb 14, 2020 · 0 comments

Comments

@fydelio
Copy link

fydelio commented Feb 14, 2020

Feature request:

It would be great if it were possible to add some conditions, under which the 2FA is not required upon login. For example if the request were to come from a trusted IP .

A possible solution could be something like this --> Add this to your login-controller

def bypass_two_factor_authentication(request)
  request.ip != '127.0.0.1'
end

Extend the lib/devise_two_factor/strategies/two_factor_authenticatable.rb

def validate_otp(resource)
    return true unless resource.otp_required_for_login **_|| bypass_two_factor_authentication == true_**
    return if params[scope]['otp_attempt'].nil?
    resource.validate_and_consume_otp!(params[scope]['otp_attempt'])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants