lockie 0.2.3 → 0.2.4
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 +4 -4
- data/README.md +20 -6
- data/lib/lockie.rb +2 -0
- data/lib/lockie/failure_app.rb +5 -2
- data/lib/lockie/rails.rb +9 -4
- data/lib/lockie/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9952a555d5390e0d3afa8a26bddab8aa1107d761d31db543ab52c09b344ce1ba
|
4
|
+
data.tar.gz: ac4384cb0a1dee463cabff6e334e9eb9ea3266c2bfecfd6ea90430a7fb4af8fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fca45221ce6b5b2303a7cb9d0884f2298c11214aecc99c16b8fe418105f180fca094136e46edd33c4c940e4e062b037af3f608c607e9845fdde66cf1c6957f33
|
7
|
+
data.tar.gz: 833cc9dbffc754cf7fb0a0fb40c437a2a9dc81996289ffa1388855972a81882559f5386530cfe675608dcea34574ff4104b06f437f069bf8a7afff1f12cf8752
|
data/README.md
CHANGED
@@ -41,9 +41,8 @@ Session controller
|
|
41
41
|
class SessionController < ApplicationController
|
42
42
|
skip_before_action :authenticate!, only: [:new]
|
43
43
|
|
44
|
-
def create
|
45
|
-
|
46
|
-
redirect_to root_url
|
44
|
+
def create
|
45
|
+
redirect_to root_url # redirect to your homepage if username and password is valid
|
47
46
|
end
|
48
47
|
|
49
48
|
def destroy
|
@@ -64,12 +63,27 @@ get 'logout' => 'session#destroy'
|
|
64
63
|
session/new.html.erb view:
|
65
64
|
```ruby
|
66
65
|
<%= form_tag(login_url) do -%>
|
67
|
-
<%= email_field_tag 'email' %>
|
68
|
-
<%= password_field_tag 'password' %>
|
69
|
-
<%= submit_tag "Login" %>
|
66
|
+
<%= email_field_tag 'email' %>
|
67
|
+
<%= password_field_tag 'password' %>
|
68
|
+
<%= submit_tag "Login" %>
|
70
69
|
<% end -%>
|
71
70
|
```
|
72
71
|
|
72
|
+
## Configuration
|
73
|
+
|
74
|
+
config/initializers/lockie.rb
|
75
|
+
```ruby
|
76
|
+
Lockie.configure do |c|
|
77
|
+
c.jwt_secret = ENV.fetch("JWT_SECRET") { "i-am-jwt-secret" }
|
78
|
+
c.model_name = "Account" # default to 'User'
|
79
|
+
c.unauthenticated_path = "/some/login/path" # default to '/login'
|
80
|
+
c.hash_algorithm = "HS512" # default to 'HS256'
|
81
|
+
|
82
|
+
# add custom warden strategy, default strategies and priority are [:email_password, :jwt]
|
83
|
+
c.default_strategies = [:auth0, :jwt]
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
73
87
|
## Contributing
|
74
88
|
Contribution directions go here.
|
75
89
|
|
data/lib/lockie.rb
CHANGED
@@ -17,12 +17,14 @@ module Lockie
|
|
17
17
|
attr_accessor :default_strategies
|
18
18
|
attr_accessor :jwt_secret
|
19
19
|
attr_accessor :hash_algorithm
|
20
|
+
attr_accessor :serialize_session
|
20
21
|
|
21
22
|
def initialize
|
22
23
|
@model_name = "User"
|
23
24
|
@unauthenticated_path = "/login"
|
24
25
|
@default_strategies = [:email_password, :jwt]
|
25
26
|
@hash_algorithm = "HS256"
|
27
|
+
@serialize_session = true
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
data/lib/lockie/failure_app.rb
CHANGED
@@ -33,11 +33,14 @@ module Lockie
|
|
33
33
|
def html_response
|
34
34
|
flash[type] = message if message
|
35
35
|
self.status = 302
|
36
|
-
|
36
|
+
callback_url = request.base_url + request.original_fullpath
|
37
|
+
uri = URI(Lockie.config.unauthenticated_path)
|
38
|
+
uri.query = (uri.query.to_s.split("&") << "callback_url=#{ callback_url }").join("&")
|
39
|
+
redirect_to uri.to_s
|
37
40
|
end
|
38
41
|
|
39
42
|
def message
|
40
|
-
@message ||= request.env['warden.message']
|
43
|
+
@message ||= request.env['warden.message'] || "Unauthorized"
|
41
44
|
end
|
42
45
|
|
43
46
|
def warden_options
|
data/lib/lockie/rails.rb
CHANGED
@@ -7,11 +7,16 @@ module Lockie
|
|
7
7
|
manager.default_strategies Lockie.config.default_strategies
|
8
8
|
manager.failure_app = Lockie::FailureApp
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
if Lockie.config.serialize_session
|
11
|
+
manager.serialize_into_session(&:email)
|
12
|
+
manager.serialize_from_session do |email|
|
13
|
+
Lockie.config.model_name.classify.constantize.find_by_email(email)
|
14
|
+
end
|
15
|
+
end
|
14
16
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
20
|
+
|
21
|
+
Warden::Manager.after_set_user do |record, warden, options|
|
22
|
+
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.2.
|
4
|
+
version: 0.2.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: 2019-
|
11
|
+
date: 2019-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|