authtrail 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -25
- data/lib/auth_trail/version.rb +1 -1
- data/lib/authtrail.rb +9 -10
- data/lib/generators/authtrail/install_generator.rb +14 -14
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9481599ae1715a613d794df663c4c6a25f15bb941e0b1043f0fda8bb34841771
|
4
|
+
data.tar.gz: 42cce2b5e242e9120e7ce9699d7da7d30f61d2cefbd7c06add65182174ab8e95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2facc0859a8c691b5512e95323b7d970a077fa0f7d9effa3701078344b507105fce23d383952c3f889ef941b869d7c53127da7911e1e5a5d57021c1cf603571
|
7
|
+
data.tar.gz: 49298c5c5094c5106daa8275ddf4298061a298690fef08469192429999e4cfd44b8e81f13c4148706d10795ebdf2cc3ce6642e6d6509ce1622a885b23d6e05d1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Track Devise login activity
|
|
4
4
|
|
5
5
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
6
6
|
|
7
|
-
[![Build Status](https://github.com/ankane/authtrail/workflows/build/badge.svg
|
7
|
+
[![Build Status](https://github.com/ankane/authtrail/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/authtrail/actions)
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -21,7 +21,7 @@ rails generate authtrail:install --encryption=lockbox
|
|
21
21
|
rails db:migrate
|
22
22
|
```
|
23
23
|
|
24
|
-
To use Active Record encryption
|
24
|
+
To use Active Record encryption, run:
|
25
25
|
|
26
26
|
```sh
|
27
27
|
rails generate authtrail:install --encryption=activerecord
|
@@ -218,29 +218,6 @@ We recommend using this in addition to Devise’s `Lockable` module and [Rack::A
|
|
218
218
|
|
219
219
|
Check out [Hardening Devise](https://ankane.org/hardening-devise) and [Secure Rails](https://github.com/ankane/secure_rails) for more best practices.
|
220
220
|
|
221
|
-
## Upgrading
|
222
|
-
|
223
|
-
### 0.4.0
|
224
|
-
|
225
|
-
There are two notable changes to geocoding:
|
226
|
-
|
227
|
-
1. Geocoding is now disabled by default (this was already the case for new installations with 0.3.0+). Check out the instructions for [how to enable it](#geocoding) (you may need to create `config/initializers/authtrail.rb`).
|
228
|
-
|
229
|
-
2. The `geocoder` gem is now an optional dependency. To use geocoding, add it to your Gemfile:
|
230
|
-
|
231
|
-
```ruby
|
232
|
-
gem "geocoder"
|
233
|
-
```
|
234
|
-
|
235
|
-
### 0.2.0
|
236
|
-
|
237
|
-
To store latitude and longitude, create a migration with:
|
238
|
-
|
239
|
-
```ruby
|
240
|
-
add_column :login_activities, :latitude, :float
|
241
|
-
add_column :login_activities, :longitude, :float
|
242
|
-
```
|
243
|
-
|
244
221
|
## History
|
245
222
|
|
246
223
|
View the [changelog](https://github.com/ankane/authtrail/blob/master/CHANGELOG.md)
|
data/lib/auth_trail/version.rb
CHANGED
data/lib/authtrail.rb
CHANGED
@@ -12,6 +12,14 @@ module AuthTrail
|
|
12
12
|
attr_accessor :exclude_method, :geocode, :track_method, :identity_method, :job_queue, :transform_method
|
13
13
|
end
|
14
14
|
self.geocode = false
|
15
|
+
self.track_method = lambda do |data|
|
16
|
+
login_activity = LoginActivity.new
|
17
|
+
data.each do |k, v|
|
18
|
+
login_activity.try("#{k}=", v)
|
19
|
+
end
|
20
|
+
login_activity.save!
|
21
|
+
AuthTrail::GeocodeJob.perform_later(login_activity) if AuthTrail.geocode
|
22
|
+
end
|
15
23
|
self.identity_method = lambda do |request, opts, user|
|
16
24
|
if user
|
17
25
|
user.try(:email)
|
@@ -46,16 +54,7 @@ module AuthTrail
|
|
46
54
|
exclude = AuthTrail.exclude_method && AuthTrail.safely(default: false) { AuthTrail.exclude_method.call(data) }
|
47
55
|
|
48
56
|
unless exclude
|
49
|
-
|
50
|
-
AuthTrail.track_method.call(data)
|
51
|
-
else
|
52
|
-
login_activity = LoginActivity.new
|
53
|
-
data.each do |k, v|
|
54
|
-
login_activity.try("#{k}=", v)
|
55
|
-
end
|
56
|
-
login_activity.save!
|
57
|
-
AuthTrail::GeocodeJob.perform_later(login_activity) if AuthTrail.geocode
|
58
|
-
end
|
57
|
+
AuthTrail.track_method.call(data)
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
@@ -6,9 +6,7 @@ module Authtrail
|
|
6
6
|
include ActiveRecord::Generators::Migration
|
7
7
|
source_root File.join(__dir__, "templates")
|
8
8
|
|
9
|
-
class_option :encryption, type: :string
|
10
|
-
# deprecated
|
11
|
-
class_option :lockbox, type: :boolean
|
9
|
+
class_option :encryption, type: :string, required: true
|
12
10
|
|
13
11
|
def copy_migration
|
14
12
|
encryption # ensure valid
|
@@ -39,8 +37,11 @@ module Authtrail
|
|
39
37
|
when "lockbox"
|
40
38
|
"t.text :identity_ciphertext\n t.string :identity_bidx, index: true"
|
41
39
|
else
|
42
|
-
|
43
|
-
|
40
|
+
if encryption == "activerecord" && mysql?
|
41
|
+
"t.string :identity, limit: 510, index: true"
|
42
|
+
else
|
43
|
+
"t.string :identity, index: true"
|
44
|
+
end
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -49,23 +50,14 @@ module Authtrail
|
|
49
50
|
when "lockbox"
|
50
51
|
"t.text :ip_ciphertext\n t.string :ip_bidx, index: true"
|
51
52
|
else
|
52
|
-
# TODO add limit: 510 for Active Record encryption + MySQL?
|
53
53
|
"t.string :ip, index: true"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
# TODO remove default
|
58
57
|
def encryption
|
59
58
|
case options[:encryption]
|
60
59
|
when "lockbox", "activerecord", "none"
|
61
60
|
options[:encryption]
|
62
|
-
when nil
|
63
|
-
if options[:lockbox]
|
64
|
-
# TODO deprecation warning
|
65
|
-
"lockbox"
|
66
|
-
else
|
67
|
-
"none"
|
68
|
-
end
|
69
61
|
else
|
70
62
|
abort "Error: encryption must be lockbox, activerecord, or none"
|
71
63
|
end
|
@@ -78,6 +70,14 @@ module Authtrail
|
|
78
70
|
"has_encrypted"
|
79
71
|
end
|
80
72
|
end
|
73
|
+
|
74
|
+
def mysql?
|
75
|
+
adapter =~ /mysql|trilogy/i
|
76
|
+
end
|
77
|
+
|
78
|
+
def adapter
|
79
|
+
ActiveRecord::Base.connection_db_config.adapter.to_s
|
80
|
+
end
|
81
81
|
end
|
82
82
|
end
|
83
83
|
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.
|
4
|
+
version: 0.6.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:
|
11
|
+
date: 2024-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7'
|
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: '
|
26
|
+
version: '7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: warden
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,14 +69,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
69
|
requirements:
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '3'
|
72
|
+
version: '3.1'
|
73
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
79
|
+
rubygems_version: 3.5.22
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Track Devise login activity
|