lockie 0.2.14 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/lockie.rb +2 -0
- data/lib/lockie/controller_helper.rb +2 -0
- data/lib/lockie/failure_app.rb +5 -2
- data/lib/lockie/rails.rb +17 -3
- data/lib/lockie/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ee73ebd0d83d510942864ae11dad538c578fa4b396fad352d6c4f1602fdfbd5
|
4
|
+
data.tar.gz: 5fce20025be471f55631caa7d6d9ce874b640b838e517662e0d26acd6f576e42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5005acb3551a23b03aa7e6e1a87e0224c054fde2e1768cf84c3d278064ab1f9ff8b525d0a4c209dfa48cf11340b74935e13a14cdaa04f7b12c6b69c7c27a71b8
|
7
|
+
data.tar.gz: a002a2bd09c46b611a0d1ac544f65c74dd93bc69c632da534d12cc3e869e93cc73bd10d1056645d6c00c63ad18474eaebc759125cc2e4331a7aa87df08449b12
|
data/README.md
CHANGED
data/lib/lockie.rb
CHANGED
@@ -21,6 +21,7 @@ module Lockie
|
|
21
21
|
attr_accessor :callback_url
|
22
22
|
attr_accessor :scopes
|
23
23
|
attr_accessor :serializer_to_session, :serializer_from_session
|
24
|
+
attr_accessor :session_timeout
|
24
25
|
|
25
26
|
def initialize
|
26
27
|
@model_name = "User"
|
@@ -32,6 +33,7 @@ module Lockie
|
|
32
33
|
@scopes = []
|
33
34
|
@serializer_to_session = nil
|
34
35
|
@serializer_from_session = nil
|
36
|
+
@session_timeout = 3.hours
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
data/lib/lockie/failure_app.rb
CHANGED
@@ -34,9 +34,12 @@ module Lockie
|
|
34
34
|
flash[type] = message if message
|
35
35
|
self.status = 302
|
36
36
|
if Lockie.config.callback_url
|
37
|
-
callback_url = request.base_url + request.original_fullpath
|
38
37
|
uri = URI(warden_options[:unauthenticated_path] || Lockie.config.unauthenticated_path)
|
39
|
-
|
38
|
+
# only add callback_url if original path is not the same with login path
|
39
|
+
unless request.original_fullpath == uri.path
|
40
|
+
callback_url = request.base_url + request.original_fullpath
|
41
|
+
uri.query = (uri.query.to_s.split("&") << "callback_url=#{ callback_url }").join("&")
|
42
|
+
end
|
40
43
|
redirect_to uri.to_s
|
41
44
|
else
|
42
45
|
redirect_to Lockie.config.unauthenticated_path
|
data/lib/lockie/rails.rb
CHANGED
@@ -8,19 +8,33 @@ module Lockie
|
|
8
8
|
manager.failure_app = Lockie::FailureApp
|
9
9
|
|
10
10
|
if Lockie.config.serialize_session
|
11
|
-
serializer_to_session = Lockie.config.serializer_to_session || proc { |u| u.
|
11
|
+
serializer_to_session = Lockie.config.serializer_to_session || proc { |u| [u.class.name, u.id] }
|
12
12
|
manager.serialize_into_session(&serializer_to_session)
|
13
|
-
serializer_from_session = Lockie.config.serializer_from_session || proc { |
|
13
|
+
serializer_from_session = Lockie.config.serializer_from_session || proc { |s| s.first.constantize.find(s.last) }
|
14
14
|
manager.serialize_from_session(&serializer_from_session)
|
15
15
|
end
|
16
16
|
|
17
17
|
Lockie.config.scopes.each do |scope|
|
18
|
-
manager.scope_defaults
|
18
|
+
manager.scope_defaults(*scope)
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
Warden::Manager.after_authentication do |record, warden, options|
|
26
|
+
session_key = "warden.uls-#{record.class.name.underscore}-#{record.id}"
|
27
|
+
warden.request.session[session_key] = (Time.now + Lockie.config.session_timeout).to_s
|
28
|
+
end
|
29
|
+
|
25
30
|
Warden::Manager.after_set_user do |record, warden, options|
|
31
|
+
session_key = "warden.uls-#{record.class.name.underscore}-#{record.id}"
|
32
|
+
last_session_access = warden.request.session[session_key]
|
33
|
+
|
34
|
+
if last_session_access && Time.parse(last_session_access) < Time.now
|
35
|
+
# session expired
|
36
|
+
warden.logout
|
37
|
+
end
|
38
|
+
|
39
|
+
warden.request.session[session_key] = Time.now + Lockie.config.session_timeout
|
26
40
|
end
|
data/lib/lockie/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lockie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Melvin Sembrano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -135,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
|
-
|
139
|
-
rubygems_version: 2.7.7
|
138
|
+
rubygems_version: 3.0.8
|
140
139
|
signing_key:
|
141
140
|
specification_version: 4
|
142
141
|
summary: Drop in password and JWT token authentication for Ruby on Rails
|