rack-ninja_auth 0.5.1 → 0.5.2
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/lib/rack/ninja_auth/version.rb +1 -1
- data/lib/rack/ninja_auth.rb +6 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc4021fdd66c583d85baee880d13fd5fdace6c4
|
4
|
+
data.tar.gz: 390eeac41894a3e9c7ed2556d8475d059447a6b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 592533dbf35bc2b2e6df24702f94ca9c8dda05e6df935cac53ad17114b0045e01f14ab841e22d5301d015d22cfb6885b1380534451fc65801224382b660d8754
|
7
|
+
data.tar.gz: d275a906c794f819ac76fca074cac984e87ca2f9bbaf8bec3eec4c70634205823391ccf2f45eb18b7a6a7988949d08038fb698335995560cb9adc46b43b76177
|
data/lib/rack/ninja_auth.rb
CHANGED
@@ -18,11 +18,10 @@ module Rack
|
|
18
18
|
provider :google_oauth2, ENV["NINJA_GOOGLE_CLIENT_ID"], ENV["NINJA_GOOGLE_CLIENT_SECRET"]
|
19
19
|
end
|
20
20
|
|
21
|
-
def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil
|
21
|
+
def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil)
|
22
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"]
|
23
23
|
@main_app = app
|
24
24
|
@email_matcher = email_matcher
|
25
|
-
@remember_original_path = remember_original_path
|
26
25
|
@secured_route_matcher = secured_routes
|
27
26
|
@not_allowed_file = not_allowed_file || ::File.expand_path('../../../views/401.html', __FILE__)
|
28
27
|
super()
|
@@ -39,10 +38,10 @@ module Rack
|
|
39
38
|
end
|
40
39
|
|
41
40
|
get '/auth/google_oauth2/callback' do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
redirect
|
41
|
+
email = request.env["omniauth.auth"].info.email rescue nil
|
42
|
+
if email && email.match(@email_matcher)
|
43
|
+
session[:user] = email
|
44
|
+
redirect '/'
|
46
45
|
else
|
47
46
|
redirect '/auth/failure'
|
48
47
|
end
|
@@ -55,7 +54,6 @@ module Rack
|
|
55
54
|
after do
|
56
55
|
if !@hit_real_app && status == 404
|
57
56
|
halt(403) unless env['rack-accept.request'].media_type?('text/html')
|
58
|
-
session[:redirect_to] = env['REQUEST_URI'] if @remember_original_path && is_internal_request?
|
59
57
|
redirect '/auth/google_oauth2'
|
60
58
|
end
|
61
59
|
end
|
@@ -67,7 +65,7 @@ module Rack
|
|
67
65
|
end
|
68
66
|
|
69
67
|
def is_protected_request?
|
70
|
-
|
68
|
+
env['PATH_INFO'].match(@secured_route_matcher)
|
71
69
|
end
|
72
70
|
|
73
71
|
def is_internal_request?
|