baarkerlounger
3 years ago
17 changed files with 39 additions and 38 deletions
@ -1,7 +0,0 @@ |
|||||||
module Devise2Fa |
|
||||||
class Engine < ::Rails::Engine |
|
||||||
ActiveSupport.on_load(:action_controller) do |
|
||||||
include Devise2Fa::Controllers::Helpers |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
@ -1,3 +0,0 @@ |
|||||||
module Devise2Fa |
|
||||||
VERSION = "3.0.0".freeze |
|
||||||
end |
|
@ -1,17 +1,17 @@ |
|||||||
Warden::Manager.after_authentication do |user, auth, options| |
Warden::Manager.after_authentication do |user, auth, options| |
||||||
if auth.env["action_dispatch.cookies"] |
if auth.env["action_dispatch.cookies"] |
||||||
expected_cookie_value = "#{user.class}-#{user.public_send(Devise.second_factor_resource_id)}" |
expected_cookie_value = "#{user.class}-#{user.public_send(Devise.second_factor_resource_id)}" |
||||||
actual_cookie_value = auth.env["action_dispatch.cookies"].signed[Devise2Fa::REMEMBER_TFA_COOKIE_NAME] |
actual_cookie_value = auth.env["action_dispatch.cookies"].signed[DeviseTwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME] |
||||||
bypass_by_cookie = actual_cookie_value == expected_cookie_value |
bypass_by_cookie = actual_cookie_value == expected_cookie_value |
||||||
end |
end |
||||||
|
|
||||||
if user.respond_to?(:need_two_factor_authentication?) && !bypass_by_cookie |
if user.respond_to?(:need_two_factor_authentication?) && !bypass_by_cookie |
||||||
if auth.session(options[:scope])[Devise2Fa::NEED_AUTHENTICATION] = user.need_two_factor_authentication?(auth.request) |
if auth.session(options[:scope])[DeviseTwoFactorAuthentication::NEED_AUTHENTICATION] = user.need_two_factor_authentication?(auth.request) |
||||||
user.send_new_otp if user.send_new_otp_after_login? |
user.send_new_otp if user.send_new_otp_after_login? |
||||||
end |
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
|
||||||
Warden::Manager.before_logout do |user, auth, _options| |
Warden::Manager.before_logout do |user, auth, _options| |
||||||
auth.cookies.delete Devise2Fa::REMEMBER_TFA_COOKIE_NAME if Devise.delete_cookie_on_logout |
auth.cookies.delete DeviseTwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME if Devise.delete_cookie_on_logout |
||||||
end |
end |
@ -1,4 +1,4 @@ |
|||||||
require 'devise2fa/hooks/two_factor_authenticatable' |
require 'devise_two_factor_authentication/hooks/two_factor_authenticatable' |
||||||
require 'rotp' |
require 'rotp' |
||||||
require 'encryptor' |
require 'encryptor' |
||||||
|
|
@ -0,0 +1,7 @@ |
|||||||
|
module DeviseTwoFactorAuthentication |
||||||
|
class Engine < ::Rails::Engine |
||||||
|
ActiveSupport.on_load(:action_controller) do |
||||||
|
include DeviseTwoFactorAuthentication::Controllers::Helpers |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -1,4 +1,4 @@ |
|||||||
module Devise2Fa |
module DeviseTwoFactorAuthentication |
||||||
module Schema |
module Schema |
||||||
def second_factor_attempts_count |
def second_factor_attempts_count |
||||||
apply_devise_schema :second_factor_attempts_count, Integer, :default => 0 |
apply_devise_schema :second_factor_attempts_count, Integer, :default => 0 |
@ -0,0 +1,3 @@ |
|||||||
|
module DeviseTwoFactorAuthentication |
||||||
|
VERSION = "3.0.0".freeze |
||||||
|
end |
Loading…
Reference in new issue