authtrail 0.2.0 → 0.2.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
2
  SHA256:
3
- metadata.gz: 9ad9a6df032f6b55c8bea0b3ee70bb9248d349abe1277e4debcf658af1f4b3f0
4
- data.tar.gz: a0d8162b461e5ed2caf2c3d2d6ab5aee10d51c31a64f475de306f5dc94c1a522
3
+ metadata.gz: 6ca58a6ac201b761a2cf30bed995135a44690ac7616770f9f1d2e74c45e23080
4
+ data.tar.gz: 3ab3c476d2b75e1697a0a1e08cdc6e0356c07e266b1839c74eea1c1c4d818023
5
5
  SHA512:
6
- metadata.gz: 60b80bfe92e7c351bbc80f7019dfe074e1dc5071a0af31940afdcf330d4b0481b8b020fbe1c3e32b50999781018a89c336a19130713e48045cf90e9d4451aad3
7
- data.tar.gz: 5507b63ddd85c0dc97a4d6cbd6b7d1fd972df6980f0d232d925a7312d02c2e65b93a6448d9dc38bf8baf61354665eda951540e031c18979fc376ee0acf19a54a
6
+ metadata.gz: b7a769b8963f67a9cc0d37e194dd1e9b936271cfbc7c88ee0f1fe72252926fc6184c01bd9abad0420231507bc99e54fc22b85916c9a0cb3cc1611c402e3436f3
7
+ data.tar.gz: 5cad0685a4773c31ef10f78380c9e64b4ca56828f9ba9eae8b4471a1b7cdd5d827b6f33c27a4963926003b199bbffad3971c98269e87c7cb850db33ad342a352
@@ -1,23 +1,27 @@
1
- ## 0.2.0
1
+ ## 0.2.1 (2020-08-17)
2
+
3
+ - Added `job_queue` option
4
+
5
+ ## 0.2.0 (2019-06-23)
2
6
 
3
7
  - Added latitude and longitude
4
8
  - `AuthTrail::GeocodeJob` now inherits from `ActiveJob::Base` instead of `ApplicationJob`
5
9
  - Removed support for Rails 4.2
6
10
 
7
- ## 0.1.3
11
+ ## 0.1.3 (2018-09-27)
8
12
 
9
13
  - Added support for Rails 4.2
10
14
 
11
- ## 0.1.2
15
+ ## 0.1.2 (2018-07-30)
12
16
 
13
17
  - Added `identity_method` option
14
18
  - Fixed geocoding
15
19
 
16
- ## 0.1.1
20
+ ## 0.1.1 (2018-07-13)
17
21
 
18
22
  - Improved strategy detection for failures
19
23
  - Fixed migration for MySQL
20
24
 
21
- ## 0.1.0
25
+ ## 0.1.0 (2017-11-07)
22
26
 
23
27
  - First release
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2019 Andrew Kane
1
+ Copyright (c) 2017-2020 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -4,6 +4,8 @@ Track Devise login activity
4
4
 
5
5
  :tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
6
6
 
7
+ [![Build Status](https://travis-ci.org/ankane/authtrail.svg?branch=master)](https://travis-ci.org/ankane/authtrail)
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application’s Gemfile:
@@ -86,7 +88,7 @@ AuthTrail.geocode = false
86
88
  Set job queue for geocoding
87
89
 
88
90
  ```ruby
89
- AuthTrail::GeocodeJob.queue_as :low
91
+ AuthTrail.job_queue = :low_priority
90
92
  ```
91
93
 
92
94
  ### Geocoding Performance
@@ -112,15 +114,12 @@ Geocoder.configure(
112
114
 
113
115
  ## Data Protection
114
116
 
115
- Protect the privacy of your users by encrypting fields that contain personal information, such as `identity` and `ip`. [attr_encrypted](https://github.com/attr-encrypted/attr_encrypted) is great for this. Use [blind_index](https://github.com/ankane/blind_index) so you can still query the fields.
117
+ Protect the privacy of your users by encrypting fields that contain personal data, such as `identity` and `ip`. [Lockbox](https://github.com/ankane/lockbox) is great for this. Use [Blind Index](https://github.com/ankane/blind_index) so you can still query the fields.
116
118
 
117
119
  ```ruby
118
120
  class LoginActivity < ApplicationRecord
119
- attr_encrypted :identity, key: ...
120
- attr_encrypted :ip, key: ...
121
-
122
- blind_index :identity, key: ...
123
- blind_index :ip, key: ...
121
+ encrypts :identity, :ip
122
+ blind_index :identity, :ip
124
123
  end
125
124
  ```
126
125
 
@@ -153,3 +152,12 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
153
152
  - Fix bugs and [submit pull requests](https://github.com/ankane/authtrail/pulls)
154
153
  - Write, clarify, or fix documentation
155
154
  - Suggest or add new features
155
+
156
+ To get started with development and testing:
157
+
158
+ ```sh
159
+ git clone https://github.com/ankane/authtrail.git
160
+ cd authtrail
161
+ bundle install
162
+ bundle exec rake test
163
+ ```
@@ -1,5 +1,9 @@
1
1
  module AuthTrail
2
2
  class GeocodeJob < ActiveJob::Base
3
+ # default queue is used if queue_as returns nil
4
+ # Rails has a test for this
5
+ queue_as { AuthTrail.job_queue }
6
+
3
7
  def perform(login_activity)
4
8
  result =
5
9
  begin
@@ -19,18 +19,16 @@ module AuthTrail
19
19
 
20
20
  def before_failure(env, opts)
21
21
  AuthTrail.safely do
22
- if opts[:message]
23
- request = ActionDispatch::Request.new(env)
22
+ request = ActionDispatch::Request.new(env)
24
23
 
25
- AuthTrail.track(
26
- strategy: detect_strategy(env["warden"]),
27
- scope: opts[:scope].to_s,
28
- identity: AuthTrail.identity_method.call(request, opts, nil),
29
- success: false,
30
- request: request,
31
- failure_reason: opts[:message].to_s
32
- )
33
- end
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
+ )
34
32
  end
35
33
  end
36
34
 
@@ -1,3 +1,3 @@
1
1
  module AuthTrail
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -9,7 +9,7 @@ require "auth_trail/version"
9
9
 
10
10
  module AuthTrail
11
11
  class << self
12
- attr_accessor :exclude_method, :geocode, :track_method, :identity_method
12
+ attr_accessor :exclude_method, :geocode, :track_method, :identity_method, :job_queue
13
13
  end
14
14
  self.geocode = true
15
15
  self.identity_method = lambda do |request, opts, user|
@@ -45,7 +45,11 @@ module AuthTrail
45
45
  if AuthTrail.track_method
46
46
  AuthTrail.track_method.call(info)
47
47
  else
48
- login_activity = LoginActivity.create!(info)
48
+ login_activity = LoginActivity.new
49
+ info.each do |k, v|
50
+ login_activity.try("#{k}=", v)
51
+ end
52
+ login_activity.save!
49
53
  AuthTrail::GeocodeJob.perform_later(login_activity) if AuthTrail.geocode
50
54
  end
51
55
  end
@@ -66,5 +70,5 @@ Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
66
70
  end
67
71
 
68
72
  Warden::Manager.before_failure do |env, opts|
69
- AuthTrail::Manager.before_failure(env, opts)
73
+ AuthTrail::Manager.before_failure(env, opts) if opts[:message]
70
74
  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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-24 00:00:00.000000000 Z
11
+ date: 2020-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -96,6 +96,62 @@ dependencies:
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
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
99
155
  requirement: !ruby/object:Gem::Requirement
100
156
  requirements:
101
157
  - - ">="
@@ -144,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
200
  - !ruby/object:Gem::Version
145
201
  version: '0'
146
202
  requirements: []
147
- rubygems_version: 3.0.3
203
+ rubygems_version: 3.1.2
148
204
  signing_key:
149
205
  specification_version: 4
150
206
  summary: Track Devise login activity