rack-ninja_auth 0.5.0 → 0.5.1
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/.travis.yml +2 -0
- data/lib/rack/ninja_auth/version.rb +1 -1
- data/lib/rack/ninja_auth.rb +6 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be08a995d934e96d9aae93e4471d1d72d0a86b91
|
4
|
+
data.tar.gz: a9760e5d4ee5ba0174cf12b104a9f61ef8b28ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e38e4d81a26880096b4e6aabb93876860da1ec9716639747693453f69ece1ddd952ff1b94dc735b7970b095fc89f7761d6e09b2b94c1d8bcb1dbee75e409e47f
|
7
|
+
data.tar.gz: 78c91bf7b4698bf03aab3f928bb55660816dabee679fda99980c53f667c0fb20e213755ca4a8254560d5d7bf43b11bf7889dc91f4c345f4f609b72f5ff37fdbb
|
data/.travis.yml
CHANGED
data/lib/rack/ninja_auth.rb
CHANGED
@@ -9,6 +9,7 @@ module Rack
|
|
9
9
|
class Middleware < Sinatra::Base
|
10
10
|
use Rack::Accept
|
11
11
|
use Rack::Session::Redis,
|
12
|
+
path: '/',
|
12
13
|
key: 'rack.ninja_auth',
|
13
14
|
expire_after: 2592000,
|
14
15
|
redis_server: ENV['NINJA_REDIS_URL'] || 'redis://127.0.0.1:6379/0/rack:ninja_auth'
|
@@ -17,10 +18,11 @@ module Rack
|
|
17
18
|
provider :google_oauth2, ENV["NINJA_GOOGLE_CLIENT_ID"], ENV["NINJA_GOOGLE_CLIENT_SECRET"]
|
18
19
|
end
|
19
20
|
|
20
|
-
def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil)
|
21
|
+
def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil, remember_original_path: true)
|
21
22
|
$stderr.puts "Please set NINJA_GOOGLE_CLIENT_ID and NINJA_GOOGLE_CLIENT_SECRET to use NinjaAuth" unless ENV["NINJA_GOOGLE_CLIENT_ID"] && ENV["NINJA_GOOGLE_CLIENT_SECRET"]
|
22
23
|
@main_app = app
|
23
24
|
@email_matcher = email_matcher
|
25
|
+
@remember_original_path = remember_original_path
|
24
26
|
@secured_route_matcher = secured_routes
|
25
27
|
@not_allowed_file = not_allowed_file || ::File.expand_path('../../../views/401.html', __FILE__)
|
26
28
|
super()
|
@@ -39,7 +41,8 @@ module Rack
|
|
39
41
|
get '/auth/google_oauth2/callback' do
|
40
42
|
if (request.env["omniauth.auth"].info.email.match(@email_matcher) rescue false)
|
41
43
|
session[:user] = request.env["omniauth.auth"].info.email
|
42
|
-
|
44
|
+
redirect_url = session[:redirect_to] if @remember_original_path
|
45
|
+
redirect redirect_url || '/'
|
43
46
|
else
|
44
47
|
redirect '/auth/failure'
|
45
48
|
end
|
@@ -52,7 +55,7 @@ module Rack
|
|
52
55
|
after do
|
53
56
|
if !@hit_real_app && status == 404
|
54
57
|
halt(403) unless env['rack-accept.request'].media_type?('text/html')
|
55
|
-
session[:redirect_to] =
|
58
|
+
session[:redirect_to] = env['REQUEST_URI'] if @remember_original_path && is_internal_request?
|
56
59
|
redirect '/auth/google_oauth2'
|
57
60
|
end
|
58
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-ninja_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Hastings-Spital
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -183,3 +183,4 @@ signing_key:
|
|
183
183
|
specification_version: 4
|
184
184
|
summary: Secure your test rigs with google.
|
185
185
|
test_files: []
|
186
|
+
has_rdoc:
|