omniauth 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of omniauth might be problematic. Click here for more details.
- data/Gemfile +13 -0
- data/README.md +12 -2
- data/lib/omniauth.rb +17 -6
- data/lib/omniauth/builder.rb +6 -0
- data/lib/omniauth/failure_endpoint.rb +44 -0
- data/lib/omniauth/form.rb +1 -0
- data/lib/omniauth/strategy.rb +45 -15
- data/lib/omniauth/version.rb +1 -1
- data/omniauth.gemspec +0 -5
- data/spec/omniauth/builder_spec.rb +21 -1
- data/spec/omniauth/failure_endpoint_spec.rb +53 -0
- data/spec/omniauth/strategy_spec.rb +25 -22
- data/spec/omniauth_spec.rb +7 -0
- data/spec/spec_helper.rb +20 -0
- metadata +21 -73
data/Gemfile
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
gem 'growl'
|
4
|
+
gem 'guard'
|
5
|
+
gem 'guard-bundler'
|
6
|
+
gem 'guard-rspec'
|
3
7
|
gem 'rack', '~> 1.4'
|
8
|
+
gem 'rb-fsevent'
|
9
|
+
#gem 'plymouth'
|
10
|
+
#gem 'pry'
|
11
|
+
#gem 'pry-nav'
|
12
|
+
|
13
|
+
platforms :jruby do
|
14
|
+
gem 'jruby-openssl'
|
15
|
+
end
|
16
|
+
|
4
17
|
gemspec
|
data/README.md
CHANGED
@@ -120,6 +120,16 @@ environment information on the callback request. It is entirely up to
|
|
120
120
|
you how you want to implement the particulars of your application's
|
121
121
|
authentication flow.
|
122
122
|
|
123
|
+
## Logging
|
124
|
+
|
125
|
+
OmniAuth supports a configurable logger. By default, OmniAuth will log
|
126
|
+
to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
# Rails application example
|
130
|
+
OmniAuth.config.logger = Rails.logger
|
131
|
+
```
|
132
|
+
|
123
133
|
## <a name="resources"></a>Resources
|
124
134
|
|
125
135
|
The [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki) has
|
@@ -129,8 +139,8 @@ OmniAuth, how it works, and how to use it.
|
|
129
139
|
|
130
140
|
## <a name="versions"></a>Supported Ruby Versions
|
131
141
|
|
132
|
-
OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, JRuby
|
133
|
-
|
142
|
+
OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, JRuby (1.8 mode), and Rubinius
|
143
|
+
(1.8 and 1.9 modes).
|
134
144
|
|
135
145
|
## <a name="license"></a>License
|
136
146
|
|
data/lib/omniauth.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'rack'
|
2
2
|
require 'singleton'
|
3
|
+
require 'logger'
|
3
4
|
|
4
5
|
module OmniAuth
|
6
|
+
class Error < StandardError; end
|
7
|
+
|
5
8
|
module Strategies
|
6
9
|
autoload :Developer, 'omniauth/strategies/developer'
|
7
10
|
end
|
@@ -11,6 +14,7 @@ module OmniAuth
|
|
11
14
|
autoload :Test, 'omniauth/test'
|
12
15
|
autoload :Form, 'omniauth/form'
|
13
16
|
autoload :AuthHash, 'omniauth/auth_hash'
|
17
|
+
autoload :FailureEndpoint, 'omniauth/failure_endpoint'
|
14
18
|
|
15
19
|
def self.strategies
|
16
20
|
@@strategies ||= []
|
@@ -19,16 +23,19 @@ module OmniAuth
|
|
19
23
|
class Configuration
|
20
24
|
include Singleton
|
21
25
|
|
26
|
+
def self.default_logger
|
27
|
+
logger = Logger.new(STDOUT)
|
28
|
+
logger.progname = "omniauth"
|
29
|
+
logger
|
30
|
+
end
|
31
|
+
|
22
32
|
@@defaults = {
|
23
33
|
:camelizations => {},
|
24
34
|
:path_prefix => '/auth',
|
25
|
-
:on_failure =>
|
26
|
-
message_key = env['omniauth.error.type']
|
27
|
-
new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
|
28
|
-
[302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
|
29
|
-
end,
|
35
|
+
:on_failure => OmniAuth::FailureEndpoint,
|
30
36
|
:form_css => Form::DEFAULT_CSS,
|
31
37
|
:test_mode => false,
|
38
|
+
:logger => default_logger,
|
32
39
|
:allowed_request_methods => [:get, :post],
|
33
40
|
:mock_auth => {
|
34
41
|
:default => AuthHash.new(
|
@@ -89,7 +96,7 @@ module OmniAuth
|
|
89
96
|
end
|
90
97
|
|
91
98
|
attr_writer :on_failure
|
92
|
-
attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host, :camelizations
|
99
|
+
attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host, :camelizations, :logger
|
93
100
|
end
|
94
101
|
|
95
102
|
def self.config
|
@@ -100,6 +107,10 @@ module OmniAuth
|
|
100
107
|
yield config
|
101
108
|
end
|
102
109
|
|
110
|
+
def self.logger
|
111
|
+
config.logger
|
112
|
+
end
|
113
|
+
|
103
114
|
def self.mock_auth_for(provider)
|
104
115
|
config.mock_auth[provider.to_sym] || config.mock_auth[:default]
|
105
116
|
end
|
data/lib/omniauth/builder.rb
CHANGED
@@ -23,6 +23,11 @@ module OmniAuth
|
|
23
23
|
OmniAuth.configure(&block)
|
24
24
|
end
|
25
25
|
|
26
|
+
def options(options = false)
|
27
|
+
return @options || {} if options == false
|
28
|
+
@options = options
|
29
|
+
end
|
30
|
+
|
26
31
|
def provider(klass, *args, &block)
|
27
32
|
if klass.is_a?(Class)
|
28
33
|
middleware = klass
|
@@ -34,6 +39,7 @@ module OmniAuth
|
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
42
|
+
args.last.is_a?(Hash) ? args.push(options.merge(args.pop)) : args.push(options)
|
37
43
|
use middleware, *args, &block
|
38
44
|
end
|
39
45
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
# This simple Rack endpoint that serves as the default
|
3
|
+
# 'failure' mechanism for OmniAuth. If a strategy fails for
|
4
|
+
# any reason this endpoint will be invoked. The default behavior
|
5
|
+
# is to redirect to `/auth/failure` except in the case of
|
6
|
+
# a development `RACK_ENV`, in which case an exception will
|
7
|
+
# be raised.
|
8
|
+
class FailureEndpoint
|
9
|
+
attr_reader :env
|
10
|
+
|
11
|
+
def self.call(env)
|
12
|
+
new(env).call
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(env)
|
16
|
+
@env = env
|
17
|
+
end
|
18
|
+
|
19
|
+
def call
|
20
|
+
raise_out! if ENV['RACK_ENV'].to_s == 'development'
|
21
|
+
redirect_to_failure
|
22
|
+
end
|
23
|
+
|
24
|
+
def raise_out!
|
25
|
+
raise env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type'])
|
26
|
+
end
|
27
|
+
|
28
|
+
def redirect_to_failure
|
29
|
+
message_key = env['omniauth.error.type']
|
30
|
+
new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}#{strategy_name_query_param}"
|
31
|
+
Rack::Response.new(["302 Moved"], 302, 'Location' => new_path).finish
|
32
|
+
end
|
33
|
+
|
34
|
+
def strategy_name_query_param
|
35
|
+
return "" unless env['omniauth.error.strategy']
|
36
|
+
"&strategy=#{env['omniauth.error.strategy'].name}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def origin_query_param
|
40
|
+
return "" unless env['omniauth.origin']
|
41
|
+
"&origin=#{Rack::Utils.escape(env['omniauth.origin'])}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/omniauth/form.rb
CHANGED
data/lib/omniauth/strategy.rb
CHANGED
@@ -142,6 +142,15 @@ module OmniAuth
|
|
142
142
|
"#<#{self.class.to_s}>"
|
143
143
|
end
|
144
144
|
|
145
|
+
# Direct access to the OmniAuth logger, automatically prefixed
|
146
|
+
# with this strategy's name.
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# log :warn, "This is a warning."
|
150
|
+
def log(level, message)
|
151
|
+
OmniAuth.logger.send(level, "(#{name}) #{message}")
|
152
|
+
end
|
153
|
+
|
145
154
|
# Duplicates this instance and runs #call! on it.
|
146
155
|
# @param [Hash] The Rack environment.
|
147
156
|
def call(env)
|
@@ -178,12 +187,16 @@ module OmniAuth
|
|
178
187
|
def request_call
|
179
188
|
setup_phase
|
180
189
|
|
190
|
+
log :info, "Request phase initiated."
|
191
|
+
|
181
192
|
#store query params from the request url, extracted in the callback_phase
|
182
193
|
session['omniauth.params'] = request.params
|
183
194
|
|
184
195
|
if options.form.respond_to?(:call)
|
196
|
+
log :info, "Rendering form from supplied Rack endpoint."
|
185
197
|
options.form.call(env)
|
186
198
|
elsif options.form
|
199
|
+
log :info, "Rendering form from underlying application."
|
187
200
|
call_app!
|
188
201
|
else
|
189
202
|
if request.params['origin']
|
@@ -198,6 +211,8 @@ module OmniAuth
|
|
198
211
|
# Performs the steps necessary to run the callback phase of a strategy.
|
199
212
|
def callback_call
|
200
213
|
setup_phase
|
214
|
+
|
215
|
+
log :info, "Callback phase initiated."
|
201
216
|
@env['omniauth.origin'] = session.delete('omniauth.origin')
|
202
217
|
@env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
|
203
218
|
@env['omniauth.params'] = session.delete('omniauth.params') || {}
|
@@ -211,11 +226,19 @@ module OmniAuth
|
|
211
226
|
end
|
212
227
|
|
213
228
|
def on_request_path?
|
214
|
-
|
229
|
+
if options.request_path.respond_to?(:call)
|
230
|
+
options.request_path.call(env)
|
231
|
+
else
|
232
|
+
on_path?(request_path)
|
233
|
+
end
|
215
234
|
end
|
216
235
|
|
217
236
|
def on_callback_path?
|
218
|
-
|
237
|
+
if options.callback_path.respond_to?(:call)
|
238
|
+
options.callback_path.call(env)
|
239
|
+
else
|
240
|
+
on_path?(callback_path)
|
241
|
+
end
|
219
242
|
end
|
220
243
|
|
221
244
|
def on_path?(path)
|
@@ -237,9 +260,6 @@ module OmniAuth
|
|
237
260
|
|
238
261
|
def mock_request_call
|
239
262
|
setup_phase
|
240
|
-
if response = call_through_to_app
|
241
|
-
return response
|
242
|
-
end
|
243
263
|
|
244
264
|
if request.params['origin']
|
245
265
|
@env['rack.session']['omniauth.origin'] = request.params['origin']
|
@@ -269,8 +289,10 @@ module OmniAuth
|
|
269
289
|
# underlying application. This will default to `/auth/:provider/setup`.
|
270
290
|
def setup_phase
|
271
291
|
if options[:setup].respond_to?(:call)
|
292
|
+
log :info, "Setup endpoint detected, running now."
|
272
293
|
options[:setup].call(env)
|
273
294
|
elsif options.setup?
|
295
|
+
log :info, "Calling through to underlying application for setup."
|
274
296
|
setup_env = env.merge('PATH_INFO' => setup_path, 'REQUEST_METHOD' => 'GET')
|
275
297
|
call_app!(setup_env)
|
276
298
|
end
|
@@ -336,12 +358,22 @@ module OmniAuth
|
|
336
358
|
options[:path_prefix] || OmniAuth.config.path_prefix
|
337
359
|
end
|
338
360
|
|
361
|
+
def custom_path(kind)
|
362
|
+
if options[kind].respond_to?(:call)
|
363
|
+
result = options[kind].call(env)
|
364
|
+
return nil unless result.is_a?(String)
|
365
|
+
result
|
366
|
+
else
|
367
|
+
options[kind]
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
339
371
|
def request_path
|
340
|
-
options[:request_path]
|
372
|
+
options[:request_path].is_a?(String) ? options[:request_path] : "#{path_prefix}/#{name}"
|
341
373
|
end
|
342
374
|
|
343
375
|
def callback_path
|
344
|
-
options[:callback_path] || "#{path_prefix}/#{name}/callback"
|
376
|
+
options[:callback_path].is_a?(String) ? options[:callback_path] : (custom_path(:request_path) || "#{path_prefix}/#{name}/callback")
|
345
377
|
end
|
346
378
|
|
347
379
|
def setup_path
|
@@ -356,14 +388,6 @@ module OmniAuth
|
|
356
388
|
request.query_string.empty? ? "" : "?#{request.query_string}"
|
357
389
|
end
|
358
390
|
|
359
|
-
def call_through_to_app
|
360
|
-
status, headers, body = *call_app!
|
361
|
-
session['query_params'] = Rack::Request.new(env).params
|
362
|
-
@response = Rack::Response.new(body, status, headers)
|
363
|
-
|
364
|
-
status == 404 ? nil : @response.finish
|
365
|
-
end
|
366
|
-
|
367
391
|
def call_app!(env = @env)
|
368
392
|
@app.call(env)
|
369
393
|
end
|
@@ -424,6 +448,12 @@ module OmniAuth
|
|
424
448
|
self.env['omniauth.error.type'] = message_key.to_sym
|
425
449
|
self.env['omniauth.error.strategy'] = self
|
426
450
|
|
451
|
+
if exception
|
452
|
+
log :error, "Authentication failure! #{message_key}: #{exception.class.to_s}, #{exception.message}"
|
453
|
+
else
|
454
|
+
log :error, "Authentication failure! #{message_key} encountered."
|
455
|
+
end
|
456
|
+
|
427
457
|
OmniAuth.config.on_failure.call(self.env)
|
428
458
|
end
|
429
459
|
|
data/lib/omniauth/version.rb
CHANGED
data/omniauth.gemspec
CHANGED
@@ -10,14 +10,9 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.add_runtime_dependency 'rack'
|
11
11
|
gem.add_runtime_dependency 'hashie', '~> 1.2'
|
12
12
|
|
13
|
-
gem.add_development_dependency 'growl'
|
14
|
-
gem.add_development_dependency 'guard'
|
15
|
-
gem.add_development_dependency 'guard-bundler'
|
16
|
-
gem.add_development_dependency 'guard-rspec'
|
17
13
|
gem.add_development_dependency 'simplecov'
|
18
14
|
gem.add_development_dependency 'rack-test'
|
19
15
|
gem.add_development_dependency 'rake'
|
20
|
-
gem.add_development_dependency 'rb-fsevent'
|
21
16
|
gem.add_development_dependency 'rdiscount'
|
22
17
|
gem.add_development_dependency 'rspec', '~> 2.8'
|
23
18
|
gem.add_development_dependency 'yard'
|
@@ -17,7 +17,7 @@ describe OmniAuth::Builder do
|
|
17
17
|
end }.should_not raise_error
|
18
18
|
end
|
19
19
|
|
20
|
-
it "should raise a helpful LoadError
|
20
|
+
it "should raise a helpful LoadError message if it can't find the class" do
|
21
21
|
expect {
|
22
22
|
OmniAuth::Builder.new(nil) do
|
23
23
|
provider :lorax
|
@@ -25,4 +25,24 @@ describe OmniAuth::Builder do
|
|
25
25
|
}.to raise_error(LoadError, "Could not find matching strategy for :lorax. You may need to install an additional gem (such as omniauth-lorax).")
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe '#options' do
|
30
|
+
it 'should merge provided options in' do
|
31
|
+
k = Class.new
|
32
|
+
b = OmniAuth::Builder.new(nil)
|
33
|
+
b.should_receive(:use).with(k, :foo => 'bar', :baz => 'tik')
|
34
|
+
|
35
|
+
b.options :foo => 'bar'
|
36
|
+
b.provider k, :baz => 'tik'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should add an argument if no options are provided' do
|
40
|
+
k = Class.new
|
41
|
+
b = OmniAuth::Builder.new(nil)
|
42
|
+
b.should_receive(:use).with(k, :foo => 'bar')
|
43
|
+
|
44
|
+
b.options :foo => 'bar'
|
45
|
+
b.provider k
|
46
|
+
end
|
47
|
+
end
|
28
48
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::FailureEndpoint do
|
4
|
+
subject{ OmniAuth::FailureEndpoint }
|
5
|
+
|
6
|
+
context 'development' do
|
7
|
+
before do
|
8
|
+
@rack_env = ENV['RACK_ENV']
|
9
|
+
ENV['RACK_ENV'] = 'development'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should raise out the error' do
|
13
|
+
expect do
|
14
|
+
subject.call('omniauth.error' => StandardError.new("Blah"))
|
15
|
+
end.to raise_error(StandardError, "Blah")
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should raise out an OmniAuth::Error if no omniauth.error is set' do
|
19
|
+
expect{ subject.call('omniauth.error.type' => 'example') }.to raise_error(OmniAuth::Error, "example")
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
ENV['RACK_ENV'] = @rack_env
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'non-development' do
|
28
|
+
let(:env){ {'omniauth.error.type' => 'invalid_request',
|
29
|
+
'omniauth.error.strategy' => ExampleStrategy.new({}) } }
|
30
|
+
|
31
|
+
it 'should be a redirect' do
|
32
|
+
status, head, body = *subject.call(env)
|
33
|
+
status.should == 302
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should include the SCRIPT_NAME' do
|
37
|
+
status, head, body = *subject.call(env.merge('SCRIPT_NAME' => '/random'))
|
38
|
+
head['Location'].should == '/random/auth/failure?message=invalid_request&strategy=test'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should respect configured path prefix' do
|
42
|
+
OmniAuth.config.stub(:path_prefix => '/boo')
|
43
|
+
status, head, body = *subject.call(env)
|
44
|
+
head["Location"].should == '/boo/failure?message=invalid_request&strategy=test'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should include the origin (escaped) if one is provided' do
|
48
|
+
env.merge! 'omniauth.origin' => '/origin-example'
|
49
|
+
status, head, body = *subject.call(env)
|
50
|
+
head['Location'].should be_include('&origin=%2Forigin-example')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,23 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
class ExampleStrategy
|
4
|
-
include OmniAuth::Strategy
|
5
|
-
option :name, 'test'
|
6
|
-
def call(env); self.call!(env) end
|
7
|
-
attr_reader :last_env
|
8
|
-
def request_phase
|
9
|
-
@fail = fail!(options[:failure]) if options[:failure]
|
10
|
-
@last_env = env
|
11
|
-
return @fail if @fail
|
12
|
-
raise "Request Phase"
|
13
|
-
end
|
14
|
-
def callback_phase
|
15
|
-
@fail = fail!(options[:failure]) if options[:failure]
|
16
|
-
@last_env = env
|
17
|
-
return @fail if @fail
|
18
|
-
raise "Callback Phase"
|
19
|
-
end
|
20
|
-
end
|
1
|
+
require 'spec_helper'
|
21
2
|
|
22
3
|
def make_env(path = '/auth/test', props = {})
|
23
4
|
{
|
@@ -365,6 +346,23 @@ describe OmniAuth::Strategy do
|
|
365
346
|
end
|
366
347
|
end
|
367
348
|
|
349
|
+
context 'dynamic paths' do
|
350
|
+
it 'should run the request phase if the custom request path evaluator is truthy' do
|
351
|
+
@options = {:request_path => lambda{|env| true}}
|
352
|
+
lambda{ strategy.call(make_env('/asoufibasfi')) }.should raise_error("Request Phase")
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'should run the callback phase if the custom callback path evaluator is truthy' do
|
356
|
+
@options = {:callback_path => lambda{|env| true}}
|
357
|
+
lambda{ strategy.call(make_env('/asoufiasod')) }.should raise_error("Callback Phase")
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'should provide a custom callback path if request_path evals to a string' do
|
361
|
+
strategy_instance = fresh_strategy.new(nil, :request_path => lambda{|env| "/auth/boo/callback/22" })
|
362
|
+
strategy_instance.callback_path.should == '/auth/boo/callback/22'
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
368
366
|
context 'custom paths' do
|
369
367
|
it 'should use a custom request_path if one is provided' do
|
370
368
|
@options = {:request_path => '/awesome'}
|
@@ -477,6 +475,11 @@ describe OmniAuth::Strategy do
|
|
477
475
|
end
|
478
476
|
|
479
477
|
context 'test mode' do
|
478
|
+
let(:app) do
|
479
|
+
# In test mode, the underlying app shouldn't be called on request phase.
|
480
|
+
lambda { |env| [404, {"Content-Type" => "text/html"}, []] }
|
481
|
+
end
|
482
|
+
|
480
483
|
before do
|
481
484
|
OmniAuth.config.test_mode = true
|
482
485
|
end
|
@@ -509,7 +512,7 @@ describe OmniAuth::Strategy do
|
|
509
512
|
end
|
510
513
|
|
511
514
|
it 'should be case insensitive on callback path' do
|
512
|
-
strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
|
515
|
+
strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).first.should == strategy.call(make_env('/auth/test/callback')).first
|
513
516
|
end
|
514
517
|
|
515
518
|
it 'should maintain query string parameters' do
|
@@ -632,4 +635,4 @@ describe OmniAuth::Strategy do
|
|
632
635
|
OmniAuth.config.test_mode = false
|
633
636
|
end
|
634
637
|
end
|
635
|
-
end
|
638
|
+
end
|
data/spec/omniauth_spec.rb
CHANGED
@@ -76,6 +76,13 @@ describe OmniAuth do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
describe '.logger' do
|
80
|
+
it 'should call through to the configured logger' do
|
81
|
+
OmniAuth.stub(:config => mock(:logger => "foo"))
|
82
|
+
OmniAuth.logger.should == "foo"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
79
86
|
describe '::Utils' do
|
80
87
|
describe '.deep_merge' do
|
81
88
|
it 'should combine hashes' do
|
data/spec/spec_helper.rb
CHANGED
@@ -8,8 +8,28 @@ require 'rack/test'
|
|
8
8
|
require 'omniauth'
|
9
9
|
require 'omniauth/test'
|
10
10
|
|
11
|
+
OmniAuth.config.logger = Logger.new("/dev/null")
|
12
|
+
|
11
13
|
RSpec.configure do |config|
|
12
14
|
config.include Rack::Test::Methods
|
13
15
|
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
14
16
|
end
|
15
17
|
|
18
|
+
class ExampleStrategy
|
19
|
+
include OmniAuth::Strategy
|
20
|
+
option :name, 'test'
|
21
|
+
def call(env); self.call!(env) end
|
22
|
+
attr_reader :last_env
|
23
|
+
def request_phase
|
24
|
+
@fail = fail!(options[:failure]) if options[:failure]
|
25
|
+
@last_env = env
|
26
|
+
return @fail if @fail
|
27
|
+
raise "Request Phase"
|
28
|
+
end
|
29
|
+
def callback_phase
|
30
|
+
@fail = fail!(options[:failure]) if options[:failure]
|
31
|
+
@last_env = env
|
32
|
+
return @fail if @fail
|
33
|
+
raise "Callback Phase"
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-04-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
17
|
-
requirement: &
|
17
|
+
requirement: &70235277856040 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70235277856040
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: hashie
|
28
|
-
requirement: &
|
28
|
+
requirement: &70235277853920 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,54 +33,10 @@ dependencies:
|
|
33
33
|
version: '1.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: growl
|
39
|
-
requirement: &70129876114380 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ! '>='
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: '0'
|
45
|
-
type: :development
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: *70129876114380
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: guard
|
50
|
-
requirement: &70129876113920 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ! '>='
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
56
|
-
type: :development
|
57
|
-
prerelease: false
|
58
|
-
version_requirements: *70129876113920
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: guard-bundler
|
61
|
-
requirement: &70129876113500 !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
|
-
requirements:
|
64
|
-
- - ! '>='
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '0'
|
67
|
-
type: :development
|
68
|
-
prerelease: false
|
69
|
-
version_requirements: *70129876113500
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: guard-rspec
|
72
|
-
requirement: &70129876113080 !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
type: :development
|
79
|
-
prerelease: false
|
80
|
-
version_requirements: *70129876113080
|
36
|
+
version_requirements: *70235277853920
|
81
37
|
- !ruby/object:Gem::Dependency
|
82
38
|
name: simplecov
|
83
|
-
requirement: &
|
39
|
+
requirement: &70235277853000 !ruby/object:Gem::Requirement
|
84
40
|
none: false
|
85
41
|
requirements:
|
86
42
|
- - ! '>='
|
@@ -88,10 +44,10 @@ dependencies:
|
|
88
44
|
version: '0'
|
89
45
|
type: :development
|
90
46
|
prerelease: false
|
91
|
-
version_requirements: *
|
47
|
+
version_requirements: *70235277853000
|
92
48
|
- !ruby/object:Gem::Dependency
|
93
49
|
name: rack-test
|
94
|
-
requirement: &
|
50
|
+
requirement: &70235277851980 !ruby/object:Gem::Requirement
|
95
51
|
none: false
|
96
52
|
requirements:
|
97
53
|
- - ! '>='
|
@@ -99,21 +55,10 @@ dependencies:
|
|
99
55
|
version: '0'
|
100
56
|
type: :development
|
101
57
|
prerelease: false
|
102
|
-
version_requirements: *
|
58
|
+
version_requirements: *70235277851980
|
103
59
|
- !ruby/object:Gem::Dependency
|
104
60
|
name: rake
|
105
|
-
requirement: &
|
106
|
-
none: false
|
107
|
-
requirements:
|
108
|
-
- - ! '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
type: :development
|
112
|
-
prerelease: false
|
113
|
-
version_requirements: *70129876111820
|
114
|
-
- !ruby/object:Gem::Dependency
|
115
|
-
name: rb-fsevent
|
116
|
-
requirement: &70129876111400 !ruby/object:Gem::Requirement
|
61
|
+
requirement: &70235277850580 !ruby/object:Gem::Requirement
|
117
62
|
none: false
|
118
63
|
requirements:
|
119
64
|
- - ! '>='
|
@@ -121,10 +66,10 @@ dependencies:
|
|
121
66
|
version: '0'
|
122
67
|
type: :development
|
123
68
|
prerelease: false
|
124
|
-
version_requirements: *
|
69
|
+
version_requirements: *70235277850580
|
125
70
|
- !ruby/object:Gem::Dependency
|
126
71
|
name: rdiscount
|
127
|
-
requirement: &
|
72
|
+
requirement: &70235277848860 !ruby/object:Gem::Requirement
|
128
73
|
none: false
|
129
74
|
requirements:
|
130
75
|
- - ! '>='
|
@@ -132,10 +77,10 @@ dependencies:
|
|
132
77
|
version: '0'
|
133
78
|
type: :development
|
134
79
|
prerelease: false
|
135
|
-
version_requirements: *
|
80
|
+
version_requirements: *70235277848860
|
136
81
|
- !ruby/object:Gem::Dependency
|
137
82
|
name: rspec
|
138
|
-
requirement: &
|
83
|
+
requirement: &70235277846620 !ruby/object:Gem::Requirement
|
139
84
|
none: false
|
140
85
|
requirements:
|
141
86
|
- - ~>
|
@@ -143,10 +88,10 @@ dependencies:
|
|
143
88
|
version: '2.8'
|
144
89
|
type: :development
|
145
90
|
prerelease: false
|
146
|
-
version_requirements: *
|
91
|
+
version_requirements: *70235277846620
|
147
92
|
- !ruby/object:Gem::Dependency
|
148
93
|
name: yard
|
149
|
-
requirement: &
|
94
|
+
requirement: &70235277845920 !ruby/object:Gem::Requirement
|
150
95
|
none: false
|
151
96
|
requirements:
|
152
97
|
- - ! '>='
|
@@ -154,7 +99,7 @@ dependencies:
|
|
154
99
|
version: '0'
|
155
100
|
type: :development
|
156
101
|
prerelease: false
|
157
|
-
version_requirements: *
|
102
|
+
version_requirements: *70235277845920
|
158
103
|
description: A generalized Rack framework for multiple-provider authentication.
|
159
104
|
email:
|
160
105
|
- michael@intridea.com
|
@@ -177,6 +122,7 @@ files:
|
|
177
122
|
- lib/omniauth.rb
|
178
123
|
- lib/omniauth/auth_hash.rb
|
179
124
|
- lib/omniauth/builder.rb
|
125
|
+
- lib/omniauth/failure_endpoint.rb
|
180
126
|
- lib/omniauth/form.rb
|
181
127
|
- lib/omniauth/strategies/developer.rb
|
182
128
|
- lib/omniauth/strategy.rb
|
@@ -188,6 +134,7 @@ files:
|
|
188
134
|
- omniauth.gemspec
|
189
135
|
- spec/omniauth/auth_hash_spec.rb
|
190
136
|
- spec/omniauth/builder_spec.rb
|
137
|
+
- spec/omniauth/failure_endpoint_spec.rb
|
191
138
|
- spec/omniauth/form_spec.rb
|
192
139
|
- spec/omniauth/strategies/developer_spec.rb
|
193
140
|
- spec/omniauth/strategy_spec.rb
|
@@ -220,6 +167,7 @@ summary: A generalized Rack framework for multiple-provider authentication.
|
|
220
167
|
test_files:
|
221
168
|
- spec/omniauth/auth_hash_spec.rb
|
222
169
|
- spec/omniauth/builder_spec.rb
|
170
|
+
- spec/omniauth/failure_endpoint_spec.rb
|
223
171
|
- spec/omniauth/form_spec.rb
|
224
172
|
- spec/omniauth/strategies/developer_spec.rb
|
225
173
|
- spec/omniauth/strategy_spec.rb
|