warden-github 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,5 @@ coverage
3
3
  pkg
4
4
  .DS_Store
5
5
  Gemfile.lock
6
+ vendor/gems
7
+ *.gem
@@ -15,6 +15,7 @@ Warden::Strategies.add(:github) do
15
15
  %(<p>Outdated ?code=#{params['code']}:</p><p>#{$!}</p><p><a href="/auth/github">Retry</a></p>)
16
16
  end
17
17
  else
18
+ env['rack.session']['return_to'] = env['REQUEST_URI']
18
19
  throw(:halt, [ 302, {'Location' => authorize_url}, [ ]])
19
20
  end
20
21
  end
@@ -41,7 +42,7 @@ Warden::Strategies.add(:github) do
41
42
  end
42
43
 
43
44
  def callback_url
44
- absolute_url(request, env['warden'].config[:github_callback_url])
45
+ absolute_url(request, env['warden'].config[:github_callback_url])
45
46
  end
46
47
 
47
48
  def absolute_url(request, suffix = nil)
@@ -54,3 +55,13 @@ Warden::Strategies.add(:github) do
54
55
  "#{request.scheme}://#{request.host}#{port_part}#{suffix}"
55
56
  end
56
57
  end
58
+
59
+ Warden::Manager.after_authentication do |user, proxy, opts|
60
+ redirect_to = proxy.env['rack.session']['return_to']
61
+ proxy.env['rack.session'].delete('return_to')
62
+ if redirect_to
63
+ response = Rack::Response.new
64
+ response.redirect redirect_to
65
+ throw :warden, response.finish
66
+ end
67
+ end
@@ -1,5 +1,5 @@
1
1
  module Warden
2
2
  module Github
3
- VERSION = "0.0.9"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
data/spec/app.rb CHANGED
@@ -32,6 +32,11 @@ module Example
32
32
  "Hello There, #{user.name}!"
33
33
  end
34
34
 
35
+ get '/redirect_to' do
36
+ ensure_authenticated
37
+ "Hello There, #{user.name}! return_to is working!"
38
+ end
39
+
35
40
  get '/auth/github/callback' do
36
41
  ensure_authenticated
37
42
  redirect '/'
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "warden-github"
6
- s.version = "0.0.9"
6
+ s.version = "0.1.0"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Corey Donohoe"]
9
9
  s.email = ["atmos@atmos.org"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-github
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 9
10
- version: 0.0.9
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Corey Donohoe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-16 00:00:00 -07:00
18
+ date: 2011-06-22 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency