authie 4.0.0 → 4.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b35fefc8e1d77c5dc713e70d46d29a2e6de782e3d3c6cb35a89f8a31f416406
|
4
|
+
data.tar.gz: f4bfa5628f66ef549e2cb0e74b87c2a503a0d49916d1a93aba7af299bc0e7d29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47793da24b501a3e3a5f26652cde36431c90f6f43b8d0e1fa8477e366b2ba6f6ee524e989dd5d2520f15b61c567320f701c29caa5c62bf1acfafc1ad1d096415
|
7
|
+
data.tar.gz: 98e9993d49250765b479e7bd37703652f381d3dc6fb2cf1d1792498b5c95f81c200bb0ea68ff09be6fe072e7141ed49876b43a0953a94fed012370bbbce5c36f
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddCountriesToAuthieSessions < ActiveRecord::Migration[6.1]
|
4
|
+
def change
|
5
|
+
add_column :authie_sessions, :login_ip_country, :string
|
6
|
+
add_column :authie_sessions, :two_factored_ip_country, :string
|
7
|
+
add_column :authie_sessions, :last_activity_ip_country, :string
|
8
|
+
end
|
9
|
+
end
|
data/lib/authie/config.rb
CHANGED
@@ -8,6 +8,7 @@ module Authie
|
|
8
8
|
attr_accessor :browser_id_cookie_name
|
9
9
|
attr_accessor :session_token_length
|
10
10
|
attr_accessor :extend_session_expiry_on_touch
|
11
|
+
attr_accessor :ip_lookup
|
11
12
|
|
12
13
|
def initialize
|
13
14
|
@session_inactivity_timeout = 12.hours
|
@@ -16,6 +17,13 @@ module Authie
|
|
16
17
|
@browser_id_cookie_name = :browser_id
|
17
18
|
@session_token_length = 64
|
18
19
|
@extend_session_expiry_on_touch = false
|
20
|
+
@lookup_ip_country_backend = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def lookup_ip_country(ip)
|
24
|
+
return nil if @lookup_ip_country_backend.nil?
|
25
|
+
|
26
|
+
@lookup_ip_country_backend.call(ip)
|
19
27
|
end
|
20
28
|
end
|
21
29
|
|
data/lib/authie/session.rb
CHANGED
@@ -96,7 +96,11 @@ module Authie
|
|
96
96
|
# @return [Authie::Session]
|
97
97
|
def touch
|
98
98
|
@session.last_activity_at = Time.now
|
99
|
+
if @controller.request.ip != @session.last_activity_ip
|
100
|
+
@session.last_activity_ip_country = Authie.config.lookup_ip_country(@controller.request.ip)
|
101
|
+
end
|
99
102
|
@session.last_activity_ip = @controller.request.ip
|
103
|
+
|
100
104
|
@session.last_activity_path = @controller.request.path
|
101
105
|
@session.requests += 1
|
102
106
|
extend_session_expiry_if_appropriate
|
@@ -124,6 +128,7 @@ module Authie
|
|
124
128
|
def mark_as_two_factored(skip: nil)
|
125
129
|
@session.two_factored_at = Time.now
|
126
130
|
@session.two_factored_ip = @controller.request.ip
|
131
|
+
@session.two_factored_ip_country = Authie.config.lookup_ip_country(@controller.request.ip)
|
127
132
|
@session.skip_two_factor = skip unless skip.nil?
|
128
133
|
@session.save!
|
129
134
|
Authie.notify(:mark_as_two_factor, session: self)
|
@@ -244,6 +249,7 @@ module Authie
|
|
244
249
|
session.browser_id = cookies[:browser_id]
|
245
250
|
session.login_at = Time.now
|
246
251
|
session.login_ip = controller.request.ip
|
252
|
+
session.login_ip_country = Authie.config.lookup_ip_country(session.login_ip)
|
247
253
|
session.host = controller.request.host
|
248
254
|
session.user_agent = controller.request.user_agent
|
249
255
|
session.expires_at = Time.now + Authie.config.persistent_session_length if persistent
|
@@ -298,9 +304,11 @@ module Authie
|
|
298
304
|
delegate :invalidate_others!, to: :session
|
299
305
|
delegate :last_activity_at, to: :session
|
300
306
|
delegate :last_activity_ip, to: :session
|
307
|
+
delegate :last_activity_ip_country, to: :session
|
301
308
|
delegate :last_activity_path, to: :session
|
302
309
|
delegate :login_at, to: :session
|
303
310
|
delegate :login_ip, to: :session
|
311
|
+
delegate :login_ip_country, to: :session
|
304
312
|
delegate :password_seen_at, to: :session
|
305
313
|
delegate :persisted?, to: :session
|
306
314
|
delegate :persistent?, to: :session
|
@@ -311,6 +319,7 @@ module Authie
|
|
311
319
|
delegate :token_hash, to: :session
|
312
320
|
delegate :two_factored_at, to: :session
|
313
321
|
delegate :two_factored_ip, to: :session
|
322
|
+
delegate :two_factored_ip_country, to: :session
|
314
323
|
delegate :two_factored?, to: :session
|
315
324
|
delegate :skip_two_factor?, to: :session
|
316
325
|
delegate :update, to: :session
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- db/migrate/20170421174100_add_index_to_token_hashes_on_authie_sessions.rb
|
46
46
|
- db/migrate/20180215152200_add_host_to_authie_sessions.rb
|
47
47
|
- db/migrate/20220502180100_add_two_factor_required_to_sessions.rb
|
48
|
+
- db/migrate/20230627165500_add_countries_to_authie_sessions.rb
|
48
49
|
- lib/authie.rb
|
49
50
|
- lib/authie/config.rb
|
50
51
|
- lib/authie/controller_delegate.rb
|