authtrail 0.1.0 → 0.1.1

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
- SHA1:
3
- metadata.gz: d09fb569715557b1fcde80bcab0990674c3950c3
4
- data.tar.gz: 4507a5bfb4536803efcc1a8d29ef04c1dd4c0717
2
+ SHA256:
3
+ metadata.gz: 0d0affe4e892e8dac1a1ddc212ebb6834ef1de340f782de0f4a19dcc230e0a51
4
+ data.tar.gz: 72b45a58e89181f07ea0c58e3875e67948287a2b1b0fc9aa627eac6be8aee5f8
5
5
  SHA512:
6
- metadata.gz: 12879861a9e98af5c5defd08ddf1f10d0aa11e04724ff56dd191a34b3ea778821e8173a4198f1221a92774db49301e8e633f064fdbc7385a7f184df7173de00d
7
- data.tar.gz: 1777a6f8bd28435970616e6dc90937301354edeb89ffb5ada0c85c531e01b07e8f138959f7313dbbd0c7ccb7add148550743425b5f90f200bfad7ca352363ad9
6
+ metadata.gz: 25b90ec6e2059c37c405e3e647cc39c12d3ece6a12697ac0403f0ca4b07c7b288ff73194c6fe07af1fed558bd94feb1e870e267dfba5fd6abd8adf5e3a6e18a2
7
+ data.tar.gz: 18428f49536b942f47d260e6d4251eaaae57c7cc6fddcb3d35fba1a3a6bb8adc8492453530569ab0c21b84181ffd2e92672ea8762ccb1c59dcb8c167c6037127
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
@@ -1,3 +1,8 @@
1
+ ## 0.1.1
2
+
3
+ - Improved strategy detection for failures
4
+ - Fixed migration for MySQL
5
+
1
6
  ## 0.1.0
2
7
 
3
8
  - First release
data/README.md CHANGED
@@ -24,7 +24,7 @@ rake db:migrate
24
24
  A `LoginActivity` record is created every time a user tries to login. You can then use this information to detect suspicious behavior. Data includes:
25
25
 
26
26
  - `scope` - Devise scope
27
- - `strategy` - `database_authenticatable` for password logins, `rememberable` for remember me cookie, or the name of the OmniAuth strategy
27
+ - `strategy` - Devise strategy
28
28
  - `identity` - email address
29
29
  - `success` - whether the login succeeded
30
30
  - `failure_reason` - if the login failed
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "rails", ">= 5"
22
+ spec.add_dependency "railties", ">= 5"
23
+ spec.add_dependency "activerecord", ">= 5"
23
24
  spec.add_dependency "warden"
24
25
  spec.add_dependency "geocoder"
25
26
 
@@ -1,3 +1,5 @@
1
+ require "rails/engine"
2
+
1
3
  module AuthTrail
2
4
  class Engine < Rails::Engine
3
5
  end
@@ -6,13 +6,10 @@ module AuthTrail
6
6
  AuthTrail.safely do
7
7
  request = ActionDispatch::Request.new(auth.env)
8
8
 
9
- strategy = auth.env["omniauth.auth"]["provider"] if auth.env["omniauth.auth"]
10
- strategy ||= auth.winning_strategy.class.name.split("::").last.underscore if auth.winning_strategy
11
- strategy ||= "database_authenticatable"
12
-
13
9
  identity = user.try(:email)
10
+
14
11
  AuthTrail.track(
15
- strategy: strategy,
12
+ strategy: detect_strategy(auth),
16
13
  scope: opts[:scope].to_s,
17
14
  identity: identity,
18
15
  success: true,
@@ -26,11 +23,13 @@ module AuthTrail
26
23
  AuthTrail.safely do
27
24
  if opts[:message]
28
25
  request = ActionDispatch::Request.new(env)
29
- identity = request.params[opts[:scope]] && request.params[opts[:scope]][:email] rescue nil
26
+
27
+ scope = opts[:scope]
28
+ identity = request.params[scope] && request.params[scope][:email] rescue nil
30
29
 
31
30
  AuthTrail.track(
32
- strategy: "database_authenticatable",
33
- scope: opts[:scope].to_s,
31
+ strategy: detect_strategy(env["warden"]),
32
+ scope: scope.to_s,
34
33
  identity: identity,
35
34
  success: false,
36
35
  request: request,
@@ -39,6 +38,15 @@ module AuthTrail
39
38
  end
40
39
  end
41
40
  end
41
+
42
+ private
43
+
44
+ def detect_strategy(auth)
45
+ strategy = auth.env["omniauth.auth"]["provider"] if auth.env["omniauth.auth"]
46
+ strategy ||= auth.winning_strategy.class.name.split("::").last.underscore if auth.winning_strategy
47
+ strategy ||= "database_authenticatable"
48
+ strategy
49
+ end
42
50
  end
43
51
  end
44
52
  end
@@ -1,3 +1,3 @@
1
1
  module AuthTrail
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,6 +1,8 @@
1
+ # dependencies
1
2
  require "geocoder"
2
- require "rails"
3
3
  require "warden"
4
+
5
+ # modules
4
6
  require "auth_trail/engine"
5
7
  require "auth_trail/manager"
6
8
  require "auth_trail/version"
@@ -3,12 +3,12 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
3
3
  create_table :login_activities do |t|
4
4
  t.text :scope
5
5
  t.text :strategy
6
- t.text :identity
6
+ t.string :identity
7
7
  t.boolean :success
8
8
  t.text :failure_reason
9
9
  t.references :user, polymorphic: true
10
10
  t.text :context
11
- t.text :ip
11
+ t.string :ip
12
12
  t.text :user_agent
13
13
  t.text :referrer
14
14
  t.text :city
@@ -19,6 +19,5 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
19
19
 
20
20
  add_index :login_activities, :identity
21
21
  add_index :login_activities, :ip
22
- add_index :login_activities, :user_id
23
22
  end
24
23
  end
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authtrail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-08 00:00:00.000000000 Z
11
+ date: 2018-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
@@ -104,7 +118,6 @@ files:
104
118
  - ".gitignore"
105
119
  - CHANGELOG.md
106
120
  - Gemfile
107
- - Gemfile.lock
108
121
  - LICENSE.txt
109
122
  - README.md
110
123
  - Rakefile
@@ -136,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
149
  version: '0'
137
150
  requirements: []
138
151
  rubyforge_project:
139
- rubygems_version: 2.6.13
152
+ rubygems_version: 2.7.7
140
153
  signing_key:
141
154
  specification_version: 4
142
155
  summary: Track Devise login activity
@@ -1,125 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- authtrail (0.1.0)
5
- geocoder
6
- rails (>= 5)
7
- warden
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- actioncable (5.1.4)
13
- actionpack (= 5.1.4)
14
- nio4r (~> 2.0)
15
- websocket-driver (~> 0.6.1)
16
- actionmailer (5.1.4)
17
- actionpack (= 5.1.4)
18
- actionview (= 5.1.4)
19
- activejob (= 5.1.4)
20
- mail (~> 2.5, >= 2.5.4)
21
- rails-dom-testing (~> 2.0)
22
- actionpack (5.1.4)
23
- actionview (= 5.1.4)
24
- activesupport (= 5.1.4)
25
- rack (~> 2.0)
26
- rack-test (>= 0.6.3)
27
- rails-dom-testing (~> 2.0)
28
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
- actionview (5.1.4)
30
- activesupport (= 5.1.4)
31
- builder (~> 3.1)
32
- erubi (~> 1.4)
33
- rails-dom-testing (~> 2.0)
34
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
35
- activejob (5.1.4)
36
- activesupport (= 5.1.4)
37
- globalid (>= 0.3.6)
38
- activemodel (5.1.4)
39
- activesupport (= 5.1.4)
40
- activerecord (5.1.4)
41
- activemodel (= 5.1.4)
42
- activesupport (= 5.1.4)
43
- arel (~> 8.0)
44
- activesupport (5.1.4)
45
- concurrent-ruby (~> 1.0, >= 1.0.2)
46
- i18n (~> 0.7)
47
- minitest (~> 5.1)
48
- tzinfo (~> 1.1)
49
- arel (8.0.0)
50
- builder (3.2.3)
51
- concurrent-ruby (1.0.5)
52
- crass (1.0.2)
53
- erubi (1.7.0)
54
- geocoder (1.4.4)
55
- globalid (0.4.1)
56
- activesupport (>= 4.2.0)
57
- i18n (0.9.1)
58
- concurrent-ruby (~> 1.0)
59
- loofah (2.1.1)
60
- crass (~> 1.0.2)
61
- nokogiri (>= 1.5.9)
62
- mail (2.7.0)
63
- mini_mime (>= 0.1.1)
64
- method_source (0.9.0)
65
- mini_mime (0.1.4)
66
- mini_portile2 (2.3.0)
67
- minitest (5.10.3)
68
- nio4r (2.1.0)
69
- nokogiri (1.8.1)
70
- mini_portile2 (~> 2.3.0)
71
- rack (2.0.3)
72
- rack-test (0.7.0)
73
- rack (>= 1.0, < 3)
74
- rails (5.1.4)
75
- actioncable (= 5.1.4)
76
- actionmailer (= 5.1.4)
77
- actionpack (= 5.1.4)
78
- actionview (= 5.1.4)
79
- activejob (= 5.1.4)
80
- activemodel (= 5.1.4)
81
- activerecord (= 5.1.4)
82
- activesupport (= 5.1.4)
83
- bundler (>= 1.3.0)
84
- railties (= 5.1.4)
85
- sprockets-rails (>= 2.0.0)
86
- rails-dom-testing (2.0.3)
87
- activesupport (>= 4.2.0)
88
- nokogiri (>= 1.6)
89
- rails-html-sanitizer (1.0.3)
90
- loofah (~> 2.0)
91
- railties (5.1.4)
92
- actionpack (= 5.1.4)
93
- activesupport (= 5.1.4)
94
- method_source
95
- rake (>= 0.8.7)
96
- thor (>= 0.18.1, < 2.0)
97
- rake (12.2.1)
98
- sprockets (3.7.1)
99
- concurrent-ruby (~> 1.0)
100
- rack (> 1, < 3)
101
- sprockets-rails (3.2.1)
102
- actionpack (>= 4.0)
103
- activesupport (>= 4.0)
104
- sprockets (>= 3.0.0)
105
- thor (0.20.0)
106
- thread_safe (0.3.6)
107
- tzinfo (1.2.4)
108
- thread_safe (~> 0.1)
109
- warden (1.2.7)
110
- rack (>= 1.0)
111
- websocket-driver (0.6.5)
112
- websocket-extensions (>= 0.1.0)
113
- websocket-extensions (0.1.2)
114
-
115
- PLATFORMS
116
- ruby
117
-
118
- DEPENDENCIES
119
- authtrail!
120
- bundler
121
- minitest
122
- rake
123
-
124
- BUNDLED WITH
125
- 1.16.0