rack-ninja_auth 0.5.0 → 0.5.1

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: b8664dcbebca4cf75ba1df44583f1ec0b6367547
4
- data.tar.gz: 1a1d64144e71a1ca69e5fa6d7986e0a311e87a91
3
+ metadata.gz: be08a995d934e96d9aae93e4471d1d72d0a86b91
4
+ data.tar.gz: a9760e5d4ee5ba0174cf12b104a9f61ef8b28ff0
5
5
  SHA512:
6
- metadata.gz: 32bb8948d54d0fd86027a0ce8cde26189c207b0834e043a2bac4a7ad12a2588df0e64cd212fadd6438a66085caa3f6806b7dc468944d3ca5351c3e187cbd582c
7
- data.tar.gz: c42e88041b2c4fa9f1c9efc6fcda2e1d18b95991dc7d0d2106e213fbfcbf07d8e6f14f813f80024f3c98e18fe213952a014402d04d3e5dbd6431168ee13fea23
6
+ metadata.gz: e38e4d81a26880096b4e6aabb93876860da1ec9716639747693453f69ece1ddd952ff1b94dc735b7970b095fc89f7761d6e09b2b94c1d8bcb1dbee75e409e47f
7
+ data.tar.gz: 78c91bf7b4698bf03aab3f928bb55660816dabee679fda99980c53f667c0fb20e213755ca4a8254560d5d7bf43b11bf7889dc91f4c345f4f609b72f5ff37fdbb
data/.travis.yml CHANGED
@@ -2,3 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - 2.2.2
4
4
  before_install: gem install bundler -v 1.10.6
5
+ services:
6
+ - redis-server
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module NinjaAuth
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
5
5
  end
@@ -9,6 +9,7 @@ module Rack
9
9
  class Middleware < Sinatra::Base
10
10
  use Rack::Accept
11
11
  use Rack::Session::Redis,
12
+ path: '/',
12
13
  key: 'rack.ninja_auth',
13
14
  expire_after: 2592000,
14
15
  redis_server: ENV['NINJA_REDIS_URL'] || 'redis://127.0.0.1:6379/0/rack:ninja_auth'
@@ -17,10 +18,11 @@ module Rack
17
18
  provider :google_oauth2, ENV["NINJA_GOOGLE_CLIENT_ID"], ENV["NINJA_GOOGLE_CLIENT_SECRET"]
18
19
  end
19
20
 
20
- def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil)
21
+ def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil, remember_original_path: true)
21
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"]
22
23
  @main_app = app
23
24
  @email_matcher = email_matcher
25
+ @remember_original_path = remember_original_path
24
26
  @secured_route_matcher = secured_routes
25
27
  @not_allowed_file = not_allowed_file || ::File.expand_path('../../../views/401.html', __FILE__)
26
28
  super()
@@ -39,7 +41,8 @@ module Rack
39
41
  get '/auth/google_oauth2/callback' do
40
42
  if (request.env["omniauth.auth"].info.email.match(@email_matcher) rescue false)
41
43
  session[:user] = request.env["omniauth.auth"].info.email
42
- redirect session[:redirect_to]
44
+ redirect_url = session[:redirect_to] if @remember_original_path
45
+ redirect redirect_url || '/'
43
46
  else
44
47
  redirect '/auth/failure'
45
48
  end
@@ -52,7 +55,7 @@ module Rack
52
55
  after do
53
56
  if !@hit_real_app && status == 404
54
57
  halt(403) unless env['rack-accept.request'].media_type?('text/html')
55
- session[:redirect_to] = is_internal_request? ? '/' : env['REQUEST_URI']
58
+ session[:redirect_to] = env['REQUEST_URI'] if @remember_original_path && is_internal_request?
56
59
  redirect '/auth/google_oauth2'
57
60
  end
58
61
  end
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.5.0
4
+ version: 0.5.1
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: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -183,3 +183,4 @@ signing_key:
183
183
  specification_version: 4
184
184
  summary: Secure your test rigs with google.
185
185
  test_files: []
186
+ has_rdoc: