rack-ninja_auth 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/ninja_auth/version.rb +1 -1
- data/lib/rack/ninja_auth.rb +9 -10
- data/views/200.html +20 -0
- 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: c05607d9320345cc6c4167b2da27e5ea9490fe5b
|
4
|
+
data.tar.gz: da48b29ed9ef6f63036e13b57d1d0b59b37e6dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea83683f11ae98c340e502407f66d863bd776a02f67e293630b5e783a114ef1fc51c6f03662342c7a9bfb12d00777a347f37e0c048408674ad78506e083b5a9b
|
7
|
+
data.tar.gz: 0ec4df77dc177086bd2f620c0eeeb2129115104001c65d3b4ebcfa11bbb380ba52bc6fecc740b32e01d49d094ad7cef670ef0d37bb0a8fa4d1350760ffaa95a2
|
data/lib/rack/ninja_auth.rb
CHANGED
@@ -15,12 +15,15 @@ module Rack
|
|
15
15
|
provider :google_oauth2, ENV["NINJA_GOOGLE_CLIENT_ID"], ENV["NINJA_GOOGLE_CLIENT_SECRET"]
|
16
16
|
end
|
17
17
|
|
18
|
-
def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil)
|
18
|
+
def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil, authorized_file: nil)
|
19
19
|
$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"]
|
20
20
|
@main_app = app
|
21
21
|
@email_matcher = email_matcher
|
22
22
|
@secured_route_matcher = secured_routes
|
23
|
-
@not_allowed_file =
|
23
|
+
@not_allowed_file = ::File.join(__dir__, '../../views/401.html')
|
24
|
+
@not_allowed_file = not_allowed_file if not_allowed_file && ::File.exists?(not_allowed_file)
|
25
|
+
@authorized_file = ::File.join(__dir__, '../../views/200.html')
|
26
|
+
@authorized_file = authorized_file if authorized_file && ::File.exists?(authorized_file)
|
24
27
|
super()
|
25
28
|
end
|
26
29
|
|
@@ -38,18 +41,14 @@ module Rack
|
|
38
41
|
email = request.env["omniauth.auth"].info.email rescue nil
|
39
42
|
if allowable_email?(email)
|
40
43
|
authenticate!(email: email)
|
41
|
-
|
44
|
+
send_file(@authorized_file, status: 200)
|
42
45
|
else
|
43
|
-
|
46
|
+
send_file(@not_allowed_file, status: 403)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
47
|
-
get '/auth/failure' do
|
48
|
-
send_file(@not_allowed_file, status: 401)
|
49
|
-
end
|
50
|
-
|
51
50
|
after do
|
52
|
-
if !@hit_real_app &&
|
51
|
+
if !@hit_real_app && !is_internal_request?
|
53
52
|
halt(403) unless env['rack-accept.request'].media_type?('text/html')
|
54
53
|
headers['X-Cascade'] = 'stop'
|
55
54
|
redirect '/auth/google_oauth2'
|
@@ -76,7 +75,7 @@ module Rack
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def is_internal_request?
|
79
|
-
!!env['REQUEST_URI'].match(%r{^/auth/})
|
78
|
+
!!env['REQUEST_URI'].match(%r{^/auth/google_oauth2})
|
80
79
|
end
|
81
80
|
end
|
82
81
|
end
|
data/views/200.html
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
3
|
+
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
4
|
+
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
5
|
+
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
|
6
|
+
<head>
|
7
|
+
<meta charset="utf-8">
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
9
|
+
<title>Not authorized</title>
|
10
|
+
<meta name="description" content="Not authorized - Ninja Auth">
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
<div class="alert">
|
15
|
+
<h1>Thanks!</h1>
|
16
|
+
<p>You've successfully authenticated, the link below will take you to the site.</p>
|
17
|
+
<p><a href="/">Go Home</a></p>
|
18
|
+
</div>
|
19
|
+
</body>
|
20
|
+
</html>
|
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.6.
|
4
|
+
version: 0.6.3
|
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: 2016-04-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/rack/ninja_auth.rb
|
144
144
|
- lib/rack/ninja_auth/version.rb
|
145
145
|
- rack-ninja_auth.gemspec
|
146
|
+
- views/200.html
|
146
147
|
- views/401.html
|
147
148
|
homepage: https://github.com/jphastings/rack-ninja_auth
|
148
149
|
licenses:
|