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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60ef8b50594dfc815315d1e66a3c4288fdeb8269
4
- data.tar.gz: b998e8dc946e9f209ba99e4c2968cf0a4481d8c6
3
+ metadata.gz: 88a38cc0bfef70c5c01d281dcf65094785c04385
4
+ data.tar.gz: fc537e1b113fe60f4e1dcf73199ef05680e20c6e
5
5
  SHA512:
6
- metadata.gz: 851e4f16a420ad75483086d01f1999b71af475cf61398bedf4e00c1cb7ef4f0bda5f6758c1949644d30d3f8156d129c92a1a8fb22002b7098fa8e58d9a0804ec
7
- data.tar.gz: a3d61f16de1ba31046df33ad11a949b59f7ca559c80cdbc2cbe7cc0b512140d7110079d08ca29b9b7113308c9f8dcb3db2649047b9ac083b33ed240adec1b057
6
+ metadata.gz: fa21fc1f600c305ebb5979614c88c00811c842fb74bcf7fa6ecf53fdd85c91df13f0e43662143d1e9c12518d5c9ac5e6d2847a89bb59a3db620ee58f5f028e9a
7
+ data.tar.gz: 3e6034c32ab80eaafc6321e9b4382db4e43aafba419e7a40c76d7784ba81c527be7890881739c37d5ef80f1ac86242c88e32bd446c2417e2b687a0fbb20ff284
data/examples/gmail.rb CHANGED
@@ -1,4 +1,4 @@
1
- $: << '../lib'
1
+ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
2
2
  # Make sure you run this with the appropriate environment variables set:
3
3
  #
4
4
  # ```
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module NinjaAuth
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -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
- send_file(@not_allowed_file, status: 401)
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']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-ninja_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Hastings-Spital