rack-ninja_auth 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/gmail.rb +1 -1
- data/lib/rack/ninja_auth/version.rb +1 -1
- data/lib/rack/ninja_auth.rb +6 -1
- 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: 88a38cc0bfef70c5c01d281dcf65094785c04385
|
4
|
+
data.tar.gz: fc537e1b113fe60f4e1dcf73199ef05680e20c6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa21fc1f600c305ebb5979614c88c00811c842fb74bcf7fa6ecf53fdd85c91df13f0e43662143d1e9c12518d5c9ac5e6d2847a89bb59a3db620ee58f5f028e9a
|
7
|
+
data.tar.gz: 3e6034c32ab80eaafc6321e9b4382db4e43aafba419e7a40c76d7784ba81c527be7890881739c37d5ef80f1ac86242c88e32bd446c2417e2b687a0fbb20ff284
|
data/examples/gmail.rb
CHANGED
data/lib/rack/ninja_auth.rb
CHANGED
@@ -9,6 +9,7 @@ module Rack
|
|
9
9
|
key: 'rack.ninja_auth',
|
10
10
|
expire_after: 2592000
|
11
11
|
|
12
|
+
raise "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"]
|
12
13
|
use OmniAuth::Builder do
|
13
14
|
provider :google_oauth2, ENV["NINJA_GOOGLE_CLIENT_ID"], ENV["NINJA_GOOGLE_CLIENT_SECRET"]
|
14
15
|
end
|
@@ -33,10 +34,14 @@ module Rack
|
|
33
34
|
session[:user] = request.env["omniauth.auth"].info.email
|
34
35
|
redirect session[:redirect_to]
|
35
36
|
else
|
36
|
-
|
37
|
+
redirect '/unauthorized'
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
41
|
+
get '/unauthorized' do
|
42
|
+
send_file(@not_allowed_file, status: 401)
|
43
|
+
end
|
44
|
+
|
40
45
|
after do
|
41
46
|
if status == 404
|
42
47
|
session[:redirect_to] = env['REQUEST_URI'] == '/auth/google_oauth2' ? '/' : env['REQUEST_URI']
|