lockie 0.4.5 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/lockie/failure_app.rb +13 -6
- data/lib/lockie/rails.rb +1 -1
- data/lib/lockie/version.rb +1 -1
- data/lib/lockie.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2da2a367021890a8009a299c6cefac92ca7d1fc055b897c8d2b0c4f3f0481cab
|
4
|
+
data.tar.gz: 53f535b09619b31b69c2ed14592651ab6d5838e47781cd759a4ef520332432fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c443dc6a9e865104f8d1795a4b6e46660a8eb6439da16d5950448d1a67382289a81775b2e5875150b160d6860718584fa6ad06f073b2ba0896e7fd3728f745b
|
7
|
+
data.tar.gz: 540634facbc3d3a5f8910794543a5e457317d887108e78b6d522a64c28ed9b348a767bfe8028f89a56a3d3e9654eee48cc086336aa69ad58ccbc8bc216fb3598
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Build Status](https://
|
1
|
+
[![Build Status](https://github.com/melvinsembrano/lockie/actions/workflows/00_test.yml/badge.svg)](https://github.com/melvinsembrano/lockie/actions/workflows/00_test.yml)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/lockie.svg)](https://badge.fury.io/rb/lockie)
|
3
3
|
|
4
4
|
# Lockie
|
@@ -9,7 +9,7 @@ A drop-in, none assuming warden based Password and JWT authentication for Rails
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'lockie', '~> 0.
|
12
|
+
gem 'lockie', '~> 0.5.2'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -82,6 +82,7 @@ Lockie.configure do |c|
|
|
82
82
|
c.model_name = "Account" # default to 'User'
|
83
83
|
c.unauthenticated_path = "/some/login/path" # default to '/login'
|
84
84
|
c.hash_algorithm = "HS512" # default to 'HS256'
|
85
|
+
c.session_timeout = 14.days
|
85
86
|
|
86
87
|
# add custom warden strategy, default strategies and priority are [:email_password, :jwt]
|
87
88
|
c.default_strategies = [:auth0, :jwt]
|
data/lib/lockie/failure_app.rb
CHANGED
@@ -13,7 +13,7 @@ module Lockie
|
|
13
13
|
def unauthenticated
|
14
14
|
if request.xhr?
|
15
15
|
api_response(:text)
|
16
|
-
elsif request.format.to_sym == :json || request.
|
16
|
+
elsif request.format.to_sym == :json || request.media_type.to_s.split("/").last == 'json'
|
17
17
|
api_response(:json)
|
18
18
|
else
|
19
19
|
html_response
|
@@ -33,21 +33,28 @@ module Lockie
|
|
33
33
|
def html_response
|
34
34
|
flash[type] = message if message
|
35
35
|
self.status = 302
|
36
|
+
|
37
|
+
unauthenticated_path = if warden_options[:scope]
|
38
|
+
warden.config.dig(:scope_defaults, warden_options[:scope], :unauthenticated_path) || Lockie.config.unauthenticated_path
|
39
|
+
else
|
40
|
+
Lockie.config.unauthenticated_path
|
41
|
+
end
|
42
|
+
|
43
|
+
uri = URI(unauthenticated_path)
|
44
|
+
|
36
45
|
if Lockie.config.callback_url
|
37
|
-
uri = URI(warden_options[:unauthenticated_path] || Lockie.config.unauthenticated_path)
|
38
46
|
# only add callback_url if original path is not the same with login path
|
39
47
|
unless request.original_fullpath == uri.path
|
40
48
|
callback_url = request.base_url + request.original_fullpath
|
41
49
|
uri.query = (uri.query.to_s.split("&") << "callback_url=#{ callback_url }").join("&")
|
42
50
|
end
|
43
|
-
redirect_to uri.to_s
|
44
|
-
else
|
45
|
-
redirect_to Lockie.config.unauthenticated_path
|
46
51
|
end
|
52
|
+
|
53
|
+
redirect_to uri.to_s
|
47
54
|
end
|
48
55
|
|
49
56
|
def message
|
50
|
-
@message ||= request.env['warden.message']
|
57
|
+
@message ||= request.env['warden.message']
|
51
58
|
end
|
52
59
|
|
53
60
|
def warden_options
|
data/lib/lockie/rails.rb
CHANGED
@@ -5,7 +5,7 @@ module Lockie
|
|
5
5
|
|
6
6
|
config.app_middleware.use Warden::Manager do |manager|
|
7
7
|
manager.default_strategies Lockie.config.default_strategies
|
8
|
-
manager.failure_app = Lockie
|
8
|
+
manager.failure_app = Lockie.config.failure_app
|
9
9
|
|
10
10
|
if Lockie.config.serialize_session
|
11
11
|
serializer_to_session = Lockie.config.serializer_to_session || proc { |u| [u.class.name, u.id] }
|
data/lib/lockie/version.rb
CHANGED
data/lib/lockie.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rails'
|
2
2
|
require 'warden'
|
3
3
|
require_relative "lockie/rails"
|
4
|
+
require_relative "lockie/failure_app"
|
4
5
|
require_relative "lockie/log_helper"
|
5
6
|
require_relative "lockie/model_helper"
|
6
7
|
require_relative "lockie/controller_helper"
|
@@ -9,7 +10,6 @@ require_relative "lockie/strategies/jwt"
|
|
9
10
|
require_relative "lockie/strategies/failed"
|
10
11
|
|
11
12
|
module Lockie
|
12
|
-
autoload :FailureApp, 'lockie/failure_app'
|
13
13
|
|
14
14
|
class Configuration
|
15
15
|
attr_accessor :model_name
|
@@ -22,6 +22,7 @@ module Lockie
|
|
22
22
|
attr_accessor :scopes
|
23
23
|
attr_accessor :serializer_to_session, :serializer_from_session
|
24
24
|
attr_accessor :session_timeout
|
25
|
+
attr_accessor :failure_app
|
25
26
|
|
26
27
|
def initialize
|
27
28
|
@model_name = "User"
|
@@ -34,6 +35,7 @@ module Lockie
|
|
34
35
|
@serializer_to_session = nil
|
35
36
|
@serializer_from_session = nil
|
36
37
|
@session_timeout = 3.hours
|
38
|
+
@failure_app = Lockie::FailureApp
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
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.5.3
|
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: 2023-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.4.10
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Drop in password and JWT token authentication for Ruby on Rails
|