authie 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -1
- data.tar.gz.sig +0 -0
- data/lib/authie/controller_delegate.rb +25 -4
- data/lib/authie/controller_extension.rb +8 -0
- data/lib/authie/engine.rb +4 -2
- data/lib/authie/session.rb +20 -4
- data/lib/authie/version.rb +1 -1
- metadata +20 -25
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65b0f0b0c1a8a8de1b9bd7759cd06cbcae80eddd
|
4
|
+
data.tar.gz: 7069b86b31ce68a03bb2070e45c4e290fa862230
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba5598c28d8179aa79bc1ebcfe2e0f3c6f924ffe687f3910ec336edb53cfd8577f753dffba2c98f3e012da93adf3fcd9b4de8c8dbaca9a07ffd53face9ded0c
|
7
|
+
data.tar.gz: 432cade42ac473df975d36c835ae8b22fca02213a62fa1febafafdf60d245f4826af4d116092d0df4b49f899a64cf1099110e359a388899f5c350ee43ed427d6
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
{�#���R��SC��0�(]�P��\=�vO<�#�����LR�; b{�*������{�o|�~QO��@�X�I��04U6CY}���G뻆�8���R�?�N}��lL�ݲ��v��t�4����5}�h�G����,7�P��#}�b�)�,�C³3Uq�מ:�0��9I��ͫ�o�A���7<��в�)�4|��Mx+�=q�]���"],C�z�"^���>�-8
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'authie/session'
|
3
|
+
|
1
4
|
module Authie
|
2
5
|
class ControllerDelegate
|
3
6
|
|
@@ -9,7 +12,7 @@ module Authie
|
|
9
12
|
def set_browser_id
|
10
13
|
until cookies[Authie.config.browser_id_cookie_name]
|
11
14
|
proposed_browser_id = SecureRandom.uuid
|
12
|
-
unless Session.where(:browser_id => proposed_browser_id).exists?
|
15
|
+
unless Authie::Session.where(:browser_id => proposed_browser_id).exists?
|
13
16
|
cookies[Authie.config.browser_id_cookie_name] = {
|
14
17
|
:value => proposed_browser_id,
|
15
18
|
:expires => 5.years.from_now,
|
@@ -36,11 +39,28 @@ module Authie
|
|
36
39
|
|
37
40
|
# Set the currently logged in user
|
38
41
|
def current_user=(user)
|
42
|
+
create_auth_session(user)
|
43
|
+
user
|
44
|
+
end
|
45
|
+
|
46
|
+
# Create a new session for the given user
|
47
|
+
def create_auth_session(user)
|
39
48
|
if user
|
40
|
-
@auth_session = Session.start(@controller, :user => user)
|
49
|
+
@auth_session = Authie::Session.start(@controller, :user => user)
|
41
50
|
else
|
42
51
|
auth_session.invalidate! if logged_in?
|
43
|
-
@auth_session =
|
52
|
+
@auth_session = :none
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Invalidate an existing auth session
|
57
|
+
def invalidate_auth_session
|
58
|
+
if logged_in?
|
59
|
+
auth_session.invalidate!
|
60
|
+
@auth_session = :none
|
61
|
+
true
|
62
|
+
else
|
63
|
+
false
|
44
64
|
end
|
45
65
|
end
|
46
66
|
|
@@ -51,7 +71,8 @@ module Authie
|
|
51
71
|
|
52
72
|
# Return the currently logged in user session
|
53
73
|
def auth_session
|
54
|
-
@auth_session ||= Session.get_session(@controller)
|
74
|
+
@auth_session ||= Authie::Session.get_session(@controller)
|
75
|
+
@auth_session == :none ? nil : @auth_session
|
55
76
|
end
|
56
77
|
|
57
78
|
private
|
@@ -31,6 +31,14 @@ module Authie
|
|
31
31
|
auth_session_delegate.current_user = user
|
32
32
|
end
|
33
33
|
|
34
|
+
def create_auth_session(user)
|
35
|
+
auth_session_delegate.create_auth_session(user)
|
36
|
+
end
|
37
|
+
|
38
|
+
def invalidate_auth_session
|
39
|
+
auth_session_delegate.invalidate_auth_session
|
40
|
+
end
|
41
|
+
|
34
42
|
def logged_in?
|
35
43
|
auth_session_delegate.logged_in?
|
36
44
|
end
|
data/lib/authie/engine.rb
CHANGED
@@ -3,9 +3,11 @@ module Authie
|
|
3
3
|
|
4
4
|
engine_name 'authie'
|
5
5
|
|
6
|
-
config.autoload_paths += Dir["#{config.root}/lib/**/"]
|
7
|
-
|
8
6
|
initializer 'authie.initialize' do |app|
|
7
|
+
ActiveSupport.on_load :active_record do
|
8
|
+
require 'authie/session'
|
9
|
+
end
|
10
|
+
|
9
11
|
ActiveSupport.on_load :action_controller do
|
10
12
|
require 'authie/controller_extension'
|
11
13
|
include Authie::ControllerExtension
|
data/lib/authie/session.rb
CHANGED
@@ -15,10 +15,6 @@ module Authie
|
|
15
15
|
self.table_name = "authie_sessions"
|
16
16
|
|
17
17
|
# Relationships
|
18
|
-
user_options = {:polymorphic => true}.merge(Authie.config.user_relationship_options)
|
19
|
-
user_options[:optional] = true if ActiveRecord::VERSION::MAJOR >= 5
|
20
|
-
belongs_to :user, user_options
|
21
|
-
|
22
18
|
parent_options = {:class_name => "Authie::Session"}
|
23
19
|
parent_options[:optional] = true if ActiveRecord::VERSION::MAJOR >= 5
|
24
20
|
belongs_to :parent, parent_options
|
@@ -36,6 +32,10 @@ module Authie
|
|
36
32
|
if self.user_agent.is_a?(String)
|
37
33
|
self.user_agent = self.user_agent[0,255]
|
38
34
|
end
|
35
|
+
|
36
|
+
if self.last_activity_path.is_a?(String)
|
37
|
+
self.last_activity_path = self.last_activity_path[0,255]
|
38
|
+
end
|
39
39
|
end
|
40
40
|
|
41
41
|
before_create do
|
@@ -51,6 +51,14 @@ module Authie
|
|
51
51
|
cookies.delete(:user_session) if controller
|
52
52
|
end
|
53
53
|
|
54
|
+
# Return the user that
|
55
|
+
def user
|
56
|
+
if self.user_id && self.user_type
|
57
|
+
@user ||= self.user_type.constantize.find_by(:id => self.user_id) || :none
|
58
|
+
@user == :none ? nil : @user
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
54
62
|
# This method should be called each time a user performs an
|
55
63
|
# action while authenticated with this session.
|
56
64
|
def touch!
|
@@ -252,7 +260,15 @@ module Authie
|
|
252
260
|
def self.start(controller, params = {})
|
253
261
|
cookies = controller.send(:cookies)
|
254
262
|
self.active.where(:browser_id => cookies[:browser_id]).each(&:invalidate!)
|
263
|
+
user_object = params.delete(:user)
|
264
|
+
|
265
|
+
if user_object.nil?
|
266
|
+
raise ActiveRecord::RecordInvalid, ':user must be provided when creating a session'
|
267
|
+
end
|
268
|
+
|
255
269
|
session = self.new(params)
|
270
|
+
session.user_type = user_object.class.to_s
|
271
|
+
session.user_id = user_object.id
|
256
272
|
session.controller = controller
|
257
273
|
session.browser_id = cookies[:browser_id]
|
258
274
|
session.login_at = Time.now
|
data/lib/authie/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -10,32 +10,27 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDZDCCAkygAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQDDAJtZTEZ
|
14
14
|
MBcGCgmSJomT8ixkARkWCWFkYW1jb29rZTESMBAGCgmSJomT8ixkARkWAmlvMB4X
|
15
|
-
|
16
|
-
BgoJkiaJk/IsZAEZFglhZGFtY29va2UxEjAQBgoJkiaJk/
|
17
|
-
|
18
|
-
|
19
|
-
/
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
giOxoHuJ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va2UuaW8wDQYJKoZIhvcNAQEFBQADggEBAK2TQPMeW9qh
|
26
|
+
NDNoVbbplfSc8/uscSP2DfssCbhXQqeDfF2z+kQpxv8iAc++KTlotqOaX5A6RvLb
|
27
|
+
NvuwMHPJRQJ2e8rbuN8Sh3tUjbkAEv3SFw4hqbKmtp0j2oKBU0dxHWNfp+5ulh2l
|
28
|
+
UXnQAt4zg3v1hTD1VrwLqG/hyk9xAaWB38lEDBuPhLrDIdDJklg9bD1E2TUvoMrg
|
29
|
+
L6TIbdP1TRrxINO1D9GzboR+OuWos7qMLBEEbjat/fQchYrW1KLcHIUCyrGkZTLm
|
30
|
+
3wUJNGnT5XYq+qvTqmjkTSTfdGvZCM63C6bGdN5CAyMokGOOatGqyCMAONolWnfC
|
31
|
+
gm3t2GWWrxY=
|
37
32
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
33
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
39
34
|
dependencies: []
|
40
35
|
description: A Rails library for storing user sessions in a backend database
|
41
36
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|