rack-ninja_auth 0.5.1 → 0.5.2

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: be08a995d934e96d9aae93e4471d1d72d0a86b91
4
- data.tar.gz: a9760e5d4ee5ba0174cf12b104a9f61ef8b28ff0
3
+ metadata.gz: cfc4021fdd66c583d85baee880d13fd5fdace6c4
4
+ data.tar.gz: 390eeac41894a3e9c7ed2556d8475d059447a6b2
5
5
  SHA512:
6
- metadata.gz: e38e4d81a26880096b4e6aabb93876860da1ec9716639747693453f69ece1ddd952ff1b94dc735b7970b095fc89f7761d6e09b2b94c1d8bcb1dbee75e409e47f
7
- data.tar.gz: 78c91bf7b4698bf03aab3f928bb55660816dabee679fda99980c53f667c0fb20e213755ca4a8254560d5d7bf43b11bf7889dc91f4c345f4f609b72f5ff37fdbb
6
+ metadata.gz: 592533dbf35bc2b2e6df24702f94ca9c8dda05e6df935cac53ad17114b0045e01f14ab841e22d5301d015d22cfb6885b1380534451fc65801224382b660d8754
7
+ data.tar.gz: d275a906c794f819ac76fca074cac984e87ca2f9bbaf8bec3eec4c70634205823391ccf2f45eb18b7a6a7988949d08038fb698335995560cb9adc46b43b76177
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module NinjaAuth
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
@@ -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, remember_original_path: true)
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
- if (request.env["omniauth.auth"].info.email.match(@email_matcher) rescue false)
43
- session[:user] = request.env["omniauth.auth"].info.email
44
- redirect_url = session[:redirect_to] if @remember_original_path
45
- redirect redirect_url || '/'
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
- is_internal_request? || env['PATH_INFO'].match(@secured_route_matcher)
68
+ env['PATH_INFO'].match(@secured_route_matcher)
71
69
  end
72
70
 
73
71
  def is_internal_request?
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.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Hastings-Spital