authtrail 0.5.0 → 0.7.0

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: b961a98fb477c8b4eeb74ee2ad5fc3ede159438538361c6d6b4dc4acee17aabf
4
- data.tar.gz: 77616ad77bce39a9223b75a289b5f4ea5c23412cdf82a76a697fdf9dad77b4f9
3
+ metadata.gz: 772039782b1938d4b3ce3b0ba5c83ddf074232156e48b103af7cc42872dc35c1
4
+ data.tar.gz: 2cf65214f9ecc836a3510b4aa9da4fbbe81383f1bfe0169c23f0357c8a95ca02
5
5
  SHA512:
6
- metadata.gz: 783acd6518405cc4f28eb9480b4556b90a188690f12d1bdb388d38316a5381dd2df55d8e65d6faa87f39ce84563ba0ddba7ef17620e82c63cda171a3abe06573
7
- data.tar.gz: 676726af0dcb1e88e5970741d374420c8f219069e86032cdd6a581f12ca09bb574b2930fff196f958741bdb2aaec73998e6f3fffe4e64970ec097bf24db8514c
6
+ metadata.gz: 3a5b5b9c67909b2598379c86dd9ebed667c3b8f3ac5c011b03445087e8aeb48674c345909d7e70bf544e247861d70c63736c1dc459aaeae059e5098ea88243e6
7
+ data.tar.gz: 360b1e2c0b6b7803ce1afcd39c38cd70c38ae758f8eb9b2d1c7f8e817f783ed61e842dcce848ea4c6ffb8ea8c74d592b2033868a460a7a913dc89fbf8da46811
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.7.0 (2025-05-04)
2
+
3
+ - Removed support for Rails < 7.1 and Ruby < 3.2
4
+
5
+ ## 0.6.0 (2024-11-11)
6
+
7
+ - Improved generator for Active Record encryption and MySQL
8
+ - Removed support for Rails < 7 and Ruby < 3.1
9
+
1
10
  ## 0.5.0 (2023-07-02)
2
11
 
3
12
  - Made Active Record and Active Job optional
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2023 Andrew Kane
1
+ Copyright (c) 2017-2025 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
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?branch=master)](https://github.com/ankane/authtrail/actions)
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 (Rails 7+, experimental), run:
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)
@@ -1,3 +1,3 @@
1
1
  module AuthTrail
2
- VERSION = "0.5.0"
2
+ VERSION = "0.7.0"
3
3
  end
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
- if AuthTrail.track_method
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
- # TODO add limit: 510 for Active Record encryption + MySQL?
43
- "t.string :identity, index: true"
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,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authtrail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-07-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '6.1'
18
+ version: '7.1'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '6.1'
25
+ version: '7.1'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: warden
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -38,7 +37,6 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
- description:
42
40
  email: andrew@ankane.org
43
41
  executables: []
44
42
  extensions: []
@@ -61,7 +59,6 @@ homepage: https://github.com/ankane/authtrail
61
59
  licenses:
62
60
  - MIT
63
61
  metadata: {}
64
- post_install_message:
65
62
  rdoc_options: []
66
63
  require_paths:
67
64
  - lib
@@ -69,15 +66,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
66
  requirements:
70
67
  - - ">="
71
68
  - !ruby/object:Gem::Version
72
- version: '3'
69
+ version: '3.2'
73
70
  required_rubygems_version: !ruby/object:Gem::Requirement
74
71
  requirements:
75
72
  - - ">="
76
73
  - !ruby/object:Gem::Version
77
74
  version: '0'
78
75
  requirements: []
79
- rubygems_version: 3.4.10
80
- signing_key:
76
+ rubygems_version: 3.6.7
81
77
  specification_version: 4
82
78
  summary: Track Devise login activity
83
79
  test_files: []