devise-suspicious_login 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8be72b66fbb34316ed86170a46b2dbd3e9c649d30f8cea5a79a5d9db15a28dc7
|
|
4
|
+
data.tar.gz: 6956d2285f93eb3df8684dc97bb3e173e4ce93dd54783e0927a5023c314d25fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed0b8483ead61c9025c6e33213ce9df207b00b907744675e6b96a0526a139d23b5fc2352a39ee290b89fb5e5db82feadb1a854494e812a610be4e140c73f89f9
|
|
7
|
+
data.tar.gz: 109530d2641ba43dca43ec4c4455432783e2340c4cad7d5e5c4095dcd0f88806d00071b019f58e9b62b28ab9760e73d93854a0a9a2398c119e973808517311da
|
data/README.md
CHANGED
|
@@ -98,6 +98,9 @@ Devise.setup do |config|
|
|
|
98
98
|
|
|
99
99
|
# Clear token on login (allows tokens to be one time use only)
|
|
100
100
|
# config.clear_token_on_login = true
|
|
101
|
+
|
|
102
|
+
# Login methods that should trigger a suspicious login (defaults to devise default login strategy)
|
|
103
|
+
#config.trigger_strategies = [Devise::Strategies::DatabaseAuthenticatable]
|
|
101
104
|
end
|
|
102
105
|
```
|
|
103
106
|
|
|
@@ -108,4 +111,4 @@ See (test/dummy/config/locales/devise.en.yml)
|
|
|
108
111
|
## Requirements
|
|
109
112
|
|
|
110
113
|
* Devise (https://github.com/plataformatec/devise)
|
|
111
|
-
* Rails 5.1 onwards (http://github.com/rails/rails)
|
|
114
|
+
* Rails 5.1 onwards (http://github.com/rails/rails)
|
|
@@ -21,6 +21,9 @@ Devise.setup do |config|
|
|
|
21
21
|
# Clear login_token after user login (true means each token can only be used once)
|
|
22
22
|
# config.clear_token_on_login = true
|
|
23
23
|
|
|
24
|
+
# Login methods that should trigger a suspicious login (defaults to devise default login strategy)
|
|
25
|
+
#config.trigger_strategies = [Devise::Strategies::DatabaseAuthenticatable]
|
|
26
|
+
|
|
24
27
|
config.warden do |manager|
|
|
25
28
|
end
|
|
26
|
-
end
|
|
29
|
+
end
|
data/lib/suspicious_login.rb
CHANGED
|
@@ -31,6 +31,9 @@ module Devise
|
|
|
31
31
|
|
|
32
32
|
mattr_accessor :clear_token_on_login
|
|
33
33
|
@@clear_token_on_login = true
|
|
34
|
+
|
|
35
|
+
mattr_accessor :trigger_strategies
|
|
36
|
+
@@trigger_strategies = ["Devise::Strategies::DatabaseAuthenticatable"]
|
|
34
37
|
end
|
|
35
38
|
|
|
36
39
|
I18n.load_path.unshift File.join(File.dirname(__FILE__), *%w[suspicious_login locales en.yml])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Warden::Manager.after_set_user except: :fetch do |user, warden, opts|
|
|
2
|
-
if warden.winning_strategy.class
|
|
2
|
+
if Devise.trigger_strategies.include?(warden.winning_strategy.class.to_s) && user && !user.token_login? && user.respond_to?(:suspicious?) && user.suspicious?(warden.request)
|
|
3
3
|
user.send_suspicious_login_instructions(warden.request) if user.login_token_sent_at.nil? || Time.now.utc - user.login_token_sent_at > Devise.resend_login_token_after
|
|
4
4
|
scope = opts[:scope]
|
|
5
5
|
warden.logout(scope) if warden.authenticated?(scope)
|