authtrail 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f88e2c20a95601d9da18766155a4eb0300ac193d7be16c56b8f293e42237163b
4
- data.tar.gz: a74f7435a461fce5c2f2c12d98cc3329aeb6f45c6e54eac6192cd5d04dd1a857
3
+ metadata.gz: e54d90f6f3527e7f9f37276deda00150f33b472069b97bd66b0d27f0a3a44c6f
4
+ data.tar.gz: aa1cd0b4fc8e01590efbd51cd872a57a3ef6e984c844166f261ebd01230a771a
5
5
  SHA512:
6
- metadata.gz: 3a572225e8e080da90c400293ebccbb6a7808f642f2469b79e0777ed37470ccec13ebd31a6f6b57d4fc6b89d037f25c1ae1980298b68b04bdc258ff71037e578
7
- data.tar.gz: 6558512fa9aa0b95932a95165c79533672f91c612116666cec6afe2743fcb7cd8357e9b230dadcab6ce503d8d8e622566c0d188d9b92cb016c37de5b46e3a09e
6
+ metadata.gz: b640a2f9705502d2405fc15d1bf4bf6082cac388addef26b3592514af117508db8b5f35306f5bd93555472f25e58a86b42d1ade276083bf4b4c4db6dea284ec8
7
+ data.tar.gz: 80475eaba75303cffdf3313706a3a58e73718804414002559780a55a1041616de61da596f9b67f79b57e71998e9c27a8c590faefdb0febaaa9834fd74b897a55
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.3.0 (2021-03-01)
2
+
3
+ - Disabled geocoding by default for new installations
4
+ - Raise an exception instead of logging when auditing fails
5
+ - Removed support for Rails < 5.2 and Ruby < 2.6
6
+
1
7
  ## 0.2.2 (2020-11-21)
2
8
 
3
9
  - Added `transform_method` option
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2020 Andrew Kane
1
+ Copyright (c) 2017-2021 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -47,7 +47,7 @@ AuthTrail.exclude_method = lambda do |data|
47
47
  end
48
48
  ```
49
49
 
50
- Add or modify data (also add new fields to the `login_activities` table)
50
+ Add or modify data - also add new fields to the `login_activities` table if needed
51
51
 
52
52
  ```ruby
53
53
  AuthTrail.transform_method = lambda do |data, request|
@@ -95,35 +95,53 @@ The `LoginActivity` model uses a [polymorphic association](https://guides.rubyon
95
95
 
96
96
  ## Geocoding
97
97
 
98
- IP geocoding is performed in a background job so it doesn’t slow down web requests. You can disable it entirely with:
98
+ AuthTrail uses [Geocoder](https://github.com/alexreisner/geocoder) for geocoding. We recommend configuring [local geocoding](#local-geocoding) so IP addresses are not sent to a 3rd party service. If you do use a 3rd party service and adhere to GDPR, be sure to add it to your subprocessor list.
99
+
100
+ To enable geocoding, update `config/initializers/authtrail.rb`:
99
101
 
100
102
  ```ruby
101
- AuthTrail.geocode = false
103
+ AuthTrail.geocode = true
102
104
  ```
103
105
 
104
- Set job queue for geocoding
106
+ Geocoding is performed in a background job so it doesn’t slow down web requests. Set the job queue with:
105
107
 
106
108
  ```ruby
107
109
  AuthTrail.job_queue = :low_priority
108
110
  ```
109
111
 
110
- ### Geocoding Performance
111
-
112
- To avoid calls to a remote API, download the [GeoLite2 City database](https://dev.maxmind.com/geoip/geoip2/geolite2/) and configure Geocoder to use it.
112
+ ### Local Geocoding
113
113
 
114
- Add this line to your application’s Gemfile:
114
+ For privacy and performance, we recommend geocoding locally. Add this line to your application’s Gemfile:
115
115
 
116
116
  ```ruby
117
117
  gem 'maxminddb'
118
118
  ```
119
119
 
120
- And create an initializer at `config/initializers/geocoder.rb` with:
120
+ For city-level geocoding, download the [GeoLite2 City database](https://dev.maxmind.com/geoip/geoip2/geolite2/) and create `config/initializers/geocoder.rb` with:
121
121
 
122
122
  ```ruby
123
123
  Geocoder.configure(
124
124
  ip_lookup: :geoip2,
125
125
  geoip2: {
126
- file: Rails.root.join("lib", "GeoLite2-City.mmdb")
126
+ file: "path/to/GeoLite2-City.mmdb"
127
+ }
128
+ )
129
+ ```
130
+
131
+ For country-level geocoding, install the `geoip-database` package. It’s preinstalled on Heroku. For Ubuntu, use:
132
+
133
+ ```sh
134
+ sudo apt-get install geoip-database
135
+ ```
136
+
137
+ And create `config/initializers/geocoder.rb` with:
138
+
139
+ ```ruby
140
+ Geocoder.configure(
141
+ ip_lookup: :maxmind_local,
142
+ maxmind_local: {
143
+ file: "/usr/share/GeoIP/GeoIP.dat",
144
+ package: :country
127
145
  }
128
146
  )
129
147
  ```
@@ -2,34 +2,29 @@ module AuthTrail
2
2
  module Manager
3
3
  class << self
4
4
  def after_set_user(user, auth, opts)
5
- # do not raise an exception for tracking
6
- AuthTrail.safely do
7
- request = ActionDispatch::Request.new(auth.env)
5
+ request = ActionDispatch::Request.new(auth.env)
8
6
 
9
- AuthTrail.track(
10
- strategy: detect_strategy(auth),
11
- scope: opts[:scope].to_s,
12
- identity: AuthTrail.identity_method.call(request, opts, user),
13
- success: true,
14
- request: request,
15
- user: user
16
- )
17
- end
7
+ AuthTrail.track(
8
+ strategy: detect_strategy(auth),
9
+ scope: opts[:scope].to_s,
10
+ identity: AuthTrail.identity_method.call(request, opts, user),
11
+ success: true,
12
+ request: request,
13
+ user: user
14
+ )
18
15
  end
19
16
 
20
17
  def before_failure(env, opts)
21
- AuthTrail.safely do
22
- request = ActionDispatch::Request.new(env)
18
+ request = ActionDispatch::Request.new(env)
23
19
 
24
- AuthTrail.track(
25
- strategy: detect_strategy(env["warden"]),
26
- scope: opts[:scope].to_s,
27
- identity: AuthTrail.identity_method.call(request, opts, nil),
28
- success: false,
29
- request: request,
30
- failure_reason: opts[:message].to_s
31
- )
32
- end
20
+ AuthTrail.track(
21
+ strategy: detect_strategy(env["warden"]),
22
+ scope: opts[:scope].to_s,
23
+ identity: AuthTrail.identity_method.call(request, opts, nil),
24
+ success: false,
25
+ request: request,
26
+ failure_reason: opts[:message].to_s
27
+ )
33
28
  end
34
29
 
35
30
  private
@@ -1,3 +1,3 @@
1
1
  module AuthTrail
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -10,6 +10,10 @@ module Authtrail
10
10
  migration_template "login_activities_migration.rb", "db/migrate/create_login_activities.rb", migration_version: migration_version
11
11
  end
12
12
 
13
+ def copy_templates
14
+ template "initializer.rb", "config/initializers/authtrail.rb"
15
+ end
16
+
13
17
  def generate_model
14
18
  template "login_activity_model.rb", "app/models/login_activity.rb"
15
19
  end
@@ -0,0 +1,14 @@
1
+ # set to true for geocoding
2
+ # we recommend configuring local geocoding first
3
+ # see https://github.com/ankane/authtrail#geocoding
4
+ AuthTrail.geocode = false
5
+
6
+ # add or modify data
7
+ # AuthTrail.transform_method = lambda do |data, request|
8
+ # data[:request_id] = request.request_id
9
+ # end
10
+
11
+ # exclude certain attempts from tracking
12
+ # AuthTrail.exclude_method = lambda do |data|
13
+ # data[:identity] == "capybara@example.org"
14
+ # end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authtrail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-22 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
26
+ version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5'
33
+ version: '5.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '5'
40
+ version: '5.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: warden
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,106 +66,8 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: bundler
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: minitest
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '5'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '5'
111
- - !ruby/object:Gem::Dependency
112
- name: combustion
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rails
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: sqlite3
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: devise
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
69
  description:
168
- email: andrew@chartkick.com
70
+ email: andrew@ankane.org
169
71
  executables: []
170
72
  extensions: []
171
73
  extra_rdoc_files: []
@@ -179,6 +81,7 @@ files:
179
81
  - lib/auth_trail/version.rb
180
82
  - lib/authtrail.rb
181
83
  - lib/generators/authtrail/install_generator.rb
84
+ - lib/generators/authtrail/templates/initializer.rb.tt
182
85
  - lib/generators/authtrail/templates/login_activities_migration.rb.tt
183
86
  - lib/generators/authtrail/templates/login_activity_model.rb.tt
184
87
  homepage: https://github.com/ankane/authtrail
@@ -193,14 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
96
  requirements:
194
97
  - - ">="
195
98
  - !ruby/object:Gem::Version
196
- version: '2.4'
99
+ version: '2.6'
197
100
  required_rubygems_version: !ruby/object:Gem::Requirement
198
101
  requirements:
199
102
  - - ">="
200
103
  - !ruby/object:Gem::Version
201
104
  version: '0'
202
105
  requirements: []
203
- rubygems_version: 3.1.4
106
+ rubygems_version: 3.2.3
204
107
  signing_key:
205
108
  specification_version: 4
206
109
  summary: Track Devise login activity