oa-core 0.1.6 → 0.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/omniauth/core.rb CHANGED
@@ -11,6 +11,10 @@ module OmniAuth
11
11
  module Strategies
12
12
  autoload :Password, 'omniauth/strategies/password'
13
13
  end
14
+
15
+ def self.strategies
16
+ @@strategies ||= []
17
+ end
14
18
 
15
19
  class Configuration
16
20
  include Singleton
@@ -60,7 +64,8 @@ module OmniAuth
60
64
  'open_id' => 'OpenID',
61
65
  'github' => 'GitHub',
62
66
  'tripit' => 'TripIt',
63
- 'soundcloud' => 'SoundCloud'
67
+ 'soundcloud' => 'SoundCloud',
68
+ 'smugmug' => 'SmugMug'
64
69
  }
65
70
 
66
71
  module_function
data/lib/omniauth/form.rb CHANGED
@@ -117,7 +117,7 @@ module OmniAuth
117
117
  </head>
118
118
  <body>
119
119
  <h1>#{title}</h1>
120
- <form method='post'>
120
+ <form method='post' noValidate='noValidate'>
121
121
  HTML
122
122
  self
123
123
  end
@@ -150,4 +150,4 @@ module OmniAuth
150
150
  "\n<style type='text/css'>#{OmniAuth.config.form_css}</style>"
151
151
  end
152
152
  end
153
- end
153
+ end
@@ -6,10 +6,10 @@ module OmniAuth
6
6
  class Password
7
7
  include OmniAuth::Strategy
8
8
 
9
- def initialize(app, secret = 'changethisappsecret', options = {})
9
+ def initialize(app, secret = 'changethisappsecret', options = {}, &block)
10
10
  @options = options
11
11
  @secret = secret
12
- super(app, :password)
12
+ super(app, :password, &block)
13
13
  end
14
14
 
15
15
  attr_reader :secret
@@ -5,14 +5,18 @@ module OmniAuth
5
5
  module Strategy
6
6
 
7
7
  def self.included(base)
8
+ OmniAuth.strategies << base
8
9
  base.class_eval do
9
- attr_reader :app, :name, :env
10
+ attr_reader :app, :name, :env, :options, :response
10
11
  end
11
12
  end
12
13
 
13
- def initialize(app, name, *args)
14
+ def initialize(app, name, *args, &block)
14
15
  @app = app
15
16
  @name = name.to_sym
17
+ @options = args.last.is_a?(Hash) ? args.pop : {}
18
+
19
+ yield self if block_given?
16
20
  end
17
21
 
18
22
  def call(env)
@@ -21,9 +25,11 @@ module OmniAuth
21
25
 
22
26
  def call!(env)
23
27
  @env = env
24
- if request.path == "#{OmniAuth.config.path_prefix}/#{name}"
28
+ if request.path == request_path
29
+ status, headers, body = *call_app!
30
+ @response = Rack::Response.new(body, status, headers)
25
31
  request_phase
26
- elsif request.path == "#{OmniAuth.config.path_prefix}/#{name}/callback"
32
+ elsif request.path == callback_path
27
33
  callback_phase
28
34
  else
29
35
  if respond_to?(:other_phase)
@@ -43,7 +49,20 @@ module OmniAuth
43
49
  call_app!
44
50
  end
45
51
 
52
+ def path_prefix
53
+ options[:path_prefix] || OmniAuth.config.path_prefix
54
+ end
55
+
56
+ def request_path
57
+ options[:request_path] || "#{path_prefix}/#{name}"
58
+ end
59
+
60
+ def callback_path
61
+ options[:callback_path] || "#{path_prefix}/#{name}/callback"
62
+ end
63
+
46
64
  def call_app!
65
+ # TODO: Remove this when we get to 0.2.0
47
66
  @env['rack.auth'] = env['omniauth.auth'] if env.key?('omniauth.auth')
48
67
  @env['rack.auth.error'] = env['omniauth.error'] if env.key?('omniauth.error')
49
68
 
@@ -65,7 +84,7 @@ module OmniAuth
65
84
  end
66
85
 
67
86
  def callback_url
68
- full_host + "#{OmniAuth.config.path_prefix}/#{name}/callback"
87
+ full_host + callback_path
69
88
  end
70
89
 
71
90
  def session
@@ -77,8 +96,15 @@ module OmniAuth
77
96
  end
78
97
 
79
98
  def redirect(uri)
80
- r = Rack::Response.new("Redirecting to #{uri}...")
81
- r.redirect(uri)
99
+ r = Rack::Response.new
100
+
101
+ if options[:iframe]
102
+ r.write("<script type='text/javascript' charset='utf-8'>top.location.href = '#{uri}';</script>")
103
+ else
104
+ r.write("Redirecting to #{uri}...")
105
+ r.redirect(uri)
106
+ end
107
+
82
108
  r.finish
83
109
  end
84
110
 
@@ -86,7 +112,10 @@ module OmniAuth
86
112
 
87
113
  def fail!(message_key, exception = nil)
88
114
  self.env['omniauth.error'] = exception
89
- OmniAuth.config.on_failure.call(self.env, message_key.to_sym)
115
+ self.env['omniauth.error.type'] = message_key.to_sym
116
+ self.env['omniauth.error.strategy'] = self
117
+
118
+ OmniAuth.config.on_failure.call(self.env)
90
119
  end
91
120
  end
92
- end
121
+ end
@@ -21,13 +21,18 @@ module OmniAuth
21
21
  module StrategyTestCase
22
22
 
23
23
  def app
24
- strategy = self.strategy
24
+ strat = self.strategy
25
+ resp = self.app_response
25
26
  Rack::Builder.new {
26
27
  use OmniAuth::Test::PhonySession
27
- use *strategy
28
- run lambda { |env| [200, {'Content-Type' => 'text/plain'}, [Rack::Request.new(env).params.key?('auth').to_s]] }
28
+ use *strat
29
+ run lambda { |env| [200, {'Content-Type' => 'text/plain'}, [resp || env.key?('omniauth.auth').to_s]] }
29
30
  }.to_app
30
31
  end
32
+
33
+ def app_response
34
+ nil
35
+ end
31
36
 
32
37
  def session
33
38
  last_request.env['rack.session']
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oa-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: -1848230051
5
+ prerelease: true
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 6
10
- version: 0.1.6
8
+ - 2
9
+ - 0
10
+ - beta1
11
+ version: 0.2.0.beta1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Michael Bleigh
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-25 00:00:00 -05:00
19
+ date: 2010-11-29 00:00:00 -06:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -168,12 +169,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
169
  required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  none: false
170
171
  requirements:
171
- - - ">="
172
+ - - ">"
172
173
  - !ruby/object:Gem::Version
173
- hash: 3
174
+ hash: 25
174
175
  segments:
175
- - 0
176
- version: "0"
176
+ - 1
177
+ - 3
178
+ - 1
179
+ version: 1.3.1
177
180
  requirements: []
178
181
 
179
182
  rubyforge_project: