|
|
@ -16,7 +16,8 @@ module Devise |
|
|
|
::Devise::Models.config( |
|
|
|
::Devise::Models.config( |
|
|
|
self, :max_login_attempts, :allowed_otp_drift_seconds, :otp_length, |
|
|
|
self, :max_login_attempts, :allowed_otp_drift_seconds, :otp_length, |
|
|
|
:remember_otp_session_for_seconds, :otp_secret_encryption_key, |
|
|
|
:remember_otp_session_for_seconds, :otp_secret_encryption_key, |
|
|
|
:direct_otp_length, :direct_otp_valid_for, :totp_timestamp, :delete_cookie_on_logout |
|
|
|
:direct_otp_length, :direct_otp_valid_for, :totp_timestamp, :delete_cookie_on_logout, |
|
|
|
|
|
|
|
:issuer, :issuer_name, :logo_url |
|
|
|
) |
|
|
|
) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -51,9 +52,16 @@ module Devise |
|
|
|
def provisioning_uri(account = nil, options = {}) |
|
|
|
def provisioning_uri(account = nil, options = {}) |
|
|
|
totp_secret = options[:otp_secret_key] || otp_secret_key |
|
|
|
totp_secret = options[:otp_secret_key] || otp_secret_key |
|
|
|
options[:digits] ||= options[:otp_length] || self.class.otp_length |
|
|
|
options[:digits] ||= options[:otp_length] || self.class.otp_length |
|
|
|
raise "provisioning_uri called with no otp_secret_key set" if totp_secret.nil? |
|
|
|
raise 'provisioning_uri called with no otp_secret_key set' if totp_secret.nil? |
|
|
|
|
|
|
|
|
|
|
|
account ||= email if respond_to?(:email) |
|
|
|
account ||= email if respond_to?(:email) |
|
|
|
ROTP::TOTP.new(totp_secret, options).provisioning_uri(account) |
|
|
|
options[:issuer] ||= self.class.issuer_name if self.class.issuer_name.present? |
|
|
|
|
|
|
|
if self.class.logo_url.blank? |
|
|
|
|
|
|
|
ROTP::TOTP.new(totp_secret, options).provisioning_uri(account) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
image = "&image=#{self.class.logo_url}" |
|
|
|
|
|
|
|
ROTP::TOTP.new(totp_secret, options).provisioning_uri(account) + image |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def need_two_factor_authentication?(request) |
|
|
|
def need_two_factor_authentication?(request) |
|
|
|