omniauth 1.0.1 → 1.0.2

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 CHANGED
@@ -1,11 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
+ gem 'rack', '~> 1.4'
3
4
  gemspec
4
-
5
- group :development do
6
- gem 'guard'
7
- gem 'guard-rspec'
8
- gem 'guard-bundler'
9
- gem 'growl'
10
- gem 'rb-fsevent'
11
- end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rack', '~> 1.3.0'
4
+ gemspec
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # OmniAuth: Standardized Multi-Provider Authentication
1
+ # OmniAuth: Standardized Multi-Provider Authentication [![CI Build Status](https://secure.travis-ci.org/intridea/omniauth.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/intridea/omniauth.png?travis)][gemnasium]
2
+
3
+ [travis]: http://travis-ci.org/intridea/omniauth
4
+ [gemnasium]: https://gemnasium.com/intridea/omniauth
2
5
 
3
6
  **OmniAuth 1.0 has several breaking changes from version 0.x. You can set
4
7
  the dependency to `~> 0.3.2` if you do not wish to make the more difficult
@@ -7,7 +10,7 @@ for more information.**
7
10
 
8
11
  ## An Introduction
9
12
 
10
- OmniAuth is a libary that standardizes multi-provider authentication for
13
+ OmniAuth is a library that standardizes multi-provider authentication for
11
14
  web applications. It was created to be powerful, flexible, and do as
12
15
  little as possible. Any developer can create **strategies** for OmniAuth
13
16
  that can authenticate users via disparate systems. OmniAuth strategies
@@ -15,11 +18,11 @@ have been created for everything from Facebook to LDAP.
15
18
 
16
19
  In order to use OmniAuth in your applications, you will need to leverage
17
20
  one or more strategies. These strategies are generally released
18
- individually as RubyGems, and you can see a [community maintained list](https://github.com/intridea/omniauth/wiki/List-of-Strategies)
21
+ individually as RubyGems, and you can see a [community maintained list](https://github.com/intridea/omniauth/wiki/List-of-Strategies)
19
22
  on the wiki for this project.
20
23
 
21
24
  One strategy, called `Developer`, is included with OmniAuth and provides
22
- a completely unsecure, non-production-usable strategy that directly
25
+ a completely insecure, non-production-usable strategy that directly
23
26
  prompts a user for authentication information and then passes it
24
27
  straight through. You can use it as a placeholder when you start
25
28
  development and easily swap in other strategies later.
@@ -117,39 +120,36 @@ environment information on the callback request. It is entirely up to
117
120
  you how you want to implement the particulars of your application's
118
121
  authentication flow.
119
122
 
120
- ## Resources
123
+ ## <a name="resources"></a>Resources
121
124
 
122
125
  The [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki) has
123
126
  actively maintained in-depth documentation for OmniAuth. It should be
124
127
  your first stop if you are wondering about a more in-depth look at
125
128
  OmniAuth, how it works, and how to use it.
126
129
 
127
- ## Supported Rubies
130
+ ## <a name="versions"></a>Supported Ruby Versions
128
131
 
129
132
  OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, JRuby, Rubinius (1.8
130
133
  mode), and Ruby Enterprise Edition.
131
134
 
132
- [![CI Build Status](https://secure.travis-ci.org/intridea/omniauth.png)](http://travis-ci.org/intridea/omniauth)
133
-
134
-
135
- ## License
135
+ ## <a name="license"></a>License
136
136
 
137
137
  Copyright (c) 2011 Intridea, Inc.
138
138
 
139
- Permission is hereby granted, free of charge, to any person obtaining a
140
- copy of this software and associated documentation files (the "Software"),
141
- to deal in the Software without restriction, including without limitation
142
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
143
- and/or sell copies of the Software, and to permit persons to whom the
139
+ Permission is hereby granted, free of charge, to any person obtaining a
140
+ copy of this software and associated documentation files (the "Software"),
141
+ to deal in the Software without restriction, including without limitation
142
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
143
+ and/or sell copies of the Software, and to permit persons to whom the
144
144
  Software is furnished to do so, subject to the following conditions:
145
145
 
146
- The above copyright notice and this permission notice shall be included
146
+ The above copyright notice and this permission notice shall be included
147
147
  in all copies or substantial portions of the Software.
148
148
 
149
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
149
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
150
150
  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
151
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
152
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
151
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
152
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
153
153
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
154
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
154
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
155
155
  DEALINGS IN THE SOFTWARE.
data/lib/omniauth.rb CHANGED
@@ -24,20 +24,20 @@ module OmniAuth
24
24
  :path_prefix => '/auth',
25
25
  :on_failure => Proc.new do |env|
26
26
  message_key = env['omniauth.error.type']
27
- new_path = "#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
27
+ new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
28
28
  [302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
29
29
  end,
30
30
  :form_css => Form::DEFAULT_CSS,
31
31
  :test_mode => false,
32
32
  :allowed_request_methods => [:get, :post],
33
33
  :mock_auth => {
34
- :default => {
34
+ :default => AuthHash.new(
35
35
  'provider' => 'default',
36
36
  'uid' => '1234',
37
37
  'info' => {
38
38
  'name' => 'Bob Example'
39
39
  }
40
- }
40
+ )
41
41
  }
42
42
  }
43
43
 
@@ -3,8 +3,16 @@ require 'omniauth'
3
3
  module OmniAuth
4
4
  class Builder < ::Rack::Builder
5
5
  def initialize(app, &block)
6
- @app = app
7
- super(&block)
6
+ if rack14?
7
+ super
8
+ else
9
+ @app = app
10
+ super(&block)
11
+ end
12
+ end
13
+
14
+ def rack14?
15
+ Rack.release.split('.')[1].to_i >= 4
8
16
  end
9
17
 
10
18
  def on_failure(&block)
@@ -30,7 +38,7 @@ module OmniAuth
30
38
  end
31
39
 
32
40
  def call(env)
33
- @ins << @app unless @ins.include?(@app)
41
+ @ins << @app unless rack14? || @ins.include?(@app)
34
42
  to_app.call(env)
35
43
  end
36
44
  end
data/lib/omniauth/form.rb CHANGED
@@ -94,6 +94,7 @@ module OmniAuth
94
94
  self.options = options
95
95
 
96
96
  @html = ""
97
+ @with_custom_button = false
97
98
  header(options[:title],options[:header_info])
98
99
  end
99
100
 
@@ -130,6 +131,7 @@ module OmniAuth
130
131
  end
131
132
 
132
133
  def button(text)
134
+ @with_custom_button = true
133
135
  @html << "\n<button type='submit'>#{text}</button>"
134
136
  end
135
137
 
@@ -162,8 +164,8 @@ module OmniAuth
162
164
 
163
165
  def footer
164
166
  return self if @footer
167
+ @html << "\n<button type='submit'>Connect</button>" unless @with_custom_button
165
168
  @html << <<-HTML
166
- <button type='submit'>Connect</button>
167
169
  </form>
168
170
  </body>
169
171
  </html>
@@ -1,3 +1,3 @@
1
1
  module OmniAuth
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/omniauth.gemspec CHANGED
@@ -10,13 +10,17 @@ 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 'maruku', '~> 0.6'
14
- gem.add_development_dependency 'simplecov', '~> 0.4'
15
- gem.add_development_dependency 'rack-test', '~> 0.5'
16
- gem.add_development_dependency 'rake', '~> 0.8'
17
- gem.add_development_dependency 'rdiscount', '~> 1.6'
18
- gem.add_development_dependency 'rspec', '~> 2.7'
19
- gem.add_development_dependency 'yard', '~> 0.7'
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
+ gem.add_development_dependency 'simplecov'
18
+ gem.add_development_dependency 'rack-test'
19
+ gem.add_development_dependency 'rake'
20
+ gem.add_development_dependency 'rb-fsevent'
21
+ gem.add_development_dependency 'rdiscount'
22
+ gem.add_development_dependency 'rspec', '~> 2.8'
23
+ gem.add_development_dependency 'yard'
20
24
 
21
25
  gem.version = OmniAuth::VERSION
22
26
  gem.files = `git ls-files`.split("\n")
@@ -496,6 +496,18 @@ describe OmniAuth::Strategy do
496
496
  response[1]['Location'].should == '/sub_uri/auth/test/callback'
497
497
  end
498
498
 
499
+ it 'should redirect on failure' do
500
+ response = OmniAuth.config.on_failure.call(make_env('/auth/test', 'omniauth.error.type' => 'error'))
501
+ response[0].should == 302
502
+ response[1]['Location'].should == '/auth/failure?message=error'
503
+ end
504
+
505
+ it 'should respect SCRIPT_NAME (a.k.a. BaseURI) on failure' do
506
+ response = OmniAuth.config.on_failure.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri', 'omniauth.error.type' => 'error'))
507
+ response[0].should == 302
508
+ response[1]['Location'].should == '/sub_uri/auth/failure?message=error'
509
+ end
510
+
499
511
  it 'should be case insensitive on callback path' do
500
512
  strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
501
513
  end
@@ -510,6 +522,8 @@ describe OmniAuth::Strategy do
510
522
  end
511
523
 
512
524
  it 'should respond with the default hash if none is set' do
525
+ OmniAuth.config.mock_auth[:test] = nil
526
+
513
527
  strategy.call make_env('/auth/test/callback')
514
528
  strategy.env['omniauth.auth']['uid'].should == '1234'
515
529
  end
@@ -546,7 +560,7 @@ describe OmniAuth::Strategy do
546
560
  strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => 'http://example.com/origin'}))
547
561
  strategy.env['omniauth.origin'].should == 'http://example.com/origin'
548
562
  end
549
-
563
+
550
564
  after do
551
565
  OmniAuth.config.test_mode = false
552
566
  end
@@ -556,7 +570,7 @@ describe OmniAuth::Strategy do
556
570
  before do
557
571
  OmniAuth.config.test_mode = true
558
572
  end
559
-
573
+
560
574
  it 'should be the string when a string is there' do
561
575
  OmniAuth.config.full_host = 'my.host.com'
562
576
  strategy.full_host.should == 'my.host.com'
@@ -567,7 +581,7 @@ describe OmniAuth::Strategy do
567
581
  strategy.call(make_env('/auth/test', 'HOST' => 'my.host.net'))
568
582
  strategy.full_host.should == 'my.host.net'
569
583
  end
570
-
584
+
571
585
  after do
572
586
  OmniAuth.config.test_mode = false
573
587
  end
@@ -578,7 +592,7 @@ describe OmniAuth::Strategy do
578
592
  before do
579
593
  OmniAuth.config.test_mode = true
580
594
  end
581
-
595
+
582
596
  context 'when options[:setup] = true' do
583
597
  let(:strategy){ ExampleStrategy.new(app, :setup => true) }
584
598
  let(:app){lambda{|env| env['omniauth.strategy'].options[:awesome] = 'sauce' if env['PATH_INFO'] == '/auth/test/setup'; [404, {}, 'Awesome'] }}
@@ -613,7 +627,7 @@ describe OmniAuth::Strategy do
613
627
  strategy.options[:awesome].should == 'sauce'
614
628
  end
615
629
  end
616
-
630
+
617
631
  after do
618
632
  OmniAuth.config.test_mode = false
619
633
  end
@@ -52,6 +52,28 @@ describe OmniAuth do
52
52
 
53
53
  OmniAuth.config.on_failure.call.should == 'yoyo'
54
54
  end
55
+ describe 'mock auth' do
56
+ before do
57
+ OmniAuth.config.add_mock(:facebook, :uid => '12345',:info=>{:name=>'Joe', :email=>'joe@example.com'})
58
+ end
59
+ it 'default should be AuthHash' do
60
+ OmniAuth.configure do |config|
61
+ config.mock_auth[:default].should be_kind_of(OmniAuth::AuthHash)
62
+ end
63
+ end
64
+ it 'facebook should be AuthHash' do
65
+ OmniAuth.configure do |config|
66
+ config.mock_auth[:facebook].should be_kind_of(OmniAuth::AuthHash)
67
+ end
68
+ end
69
+ it 'should set facebook attributes' do
70
+ OmniAuth.configure do |config|
71
+ config.mock_auth[:facebook].uid.should eq('12345')
72
+ config.mock_auth[:facebook].info.name.should eq('Joe')
73
+ config.mock_auth[:facebook].info.email.should eq('joe@example.com')
74
+ end
75
+ end
76
+ end
55
77
  end
56
78
 
57
79
  describe '::Utils' do
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.1
4
+ version: 1.0.2
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: 2011-11-25 00:00:00.000000000Z
13
+ date: 2012-01-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
17
- requirement: &70297966785140 !ruby/object:Gem::Requirement
17
+ requirement: &70122274715460 !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: *70297966785140
25
+ version_requirements: *70122274715460
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: hashie
28
- requirement: &70297966784640 !ruby/object:Gem::Requirement
28
+ requirement: &70122274714780 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,84 +33,128 @@ dependencies:
33
33
  version: '1.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70297966784640
36
+ version_requirements: *70122274714780
37
37
  - !ruby/object:Gem::Dependency
38
- name: maruku
39
- requirement: &70297966784140 !ruby/object:Gem::Requirement
38
+ name: growl
39
+ requirement: &70122274714040 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
- - - ~>
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70122274714040
48
+ - !ruby/object:Gem::Dependency
49
+ name: guard
50
+ requirement: &70122274713040 !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: *70122274713040
59
+ - !ruby/object:Gem::Dependency
60
+ name: guard-bundler
61
+ requirement: &70122274712400 !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: *70122274712400
70
+ - !ruby/object:Gem::Dependency
71
+ name: guard-rspec
72
+ requirement: &70122274711600 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
43
76
  - !ruby/object:Gem::Version
44
- version: '0.6'
77
+ version: '0'
45
78
  type: :development
46
79
  prerelease: false
47
- version_requirements: *70297966784140
80
+ version_requirements: *70122274711600
48
81
  - !ruby/object:Gem::Dependency
49
82
  name: simplecov
50
- requirement: &70297966783680 !ruby/object:Gem::Requirement
83
+ requirement: &70122274573840 !ruby/object:Gem::Requirement
51
84
  none: false
52
85
  requirements:
53
- - - ~>
86
+ - - ! '>='
54
87
  - !ruby/object:Gem::Version
55
- version: '0.4'
88
+ version: '0'
56
89
  type: :development
57
90
  prerelease: false
58
- version_requirements: *70297966783680
91
+ version_requirements: *70122274573840
59
92
  - !ruby/object:Gem::Dependency
60
93
  name: rack-test
61
- requirement: &70297966783220 !ruby/object:Gem::Requirement
94
+ requirement: &70122274572580 !ruby/object:Gem::Requirement
62
95
  none: false
63
96
  requirements:
64
- - - ~>
97
+ - - ! '>='
65
98
  - !ruby/object:Gem::Version
66
- version: '0.5'
99
+ version: '0'
67
100
  type: :development
68
101
  prerelease: false
69
- version_requirements: *70297966783220
102
+ version_requirements: *70122274572580
70
103
  - !ruby/object:Gem::Dependency
71
104
  name: rake
72
- requirement: &70297966782760 !ruby/object:Gem::Requirement
105
+ requirement: &70122274571680 !ruby/object:Gem::Requirement
73
106
  none: false
74
107
  requirements:
75
- - - ~>
108
+ - - ! '>='
76
109
  - !ruby/object:Gem::Version
77
- version: '0.8'
110
+ version: '0'
78
111
  type: :development
79
112
  prerelease: false
80
- version_requirements: *70297966782760
113
+ version_requirements: *70122274571680
114
+ - !ruby/object:Gem::Dependency
115
+ name: rb-fsevent
116
+ requirement: &70122274571120 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: *70122274571120
81
125
  - !ruby/object:Gem::Dependency
82
126
  name: rdiscount
83
- requirement: &70297966782300 !ruby/object:Gem::Requirement
127
+ requirement: &70122274570500 !ruby/object:Gem::Requirement
84
128
  none: false
85
129
  requirements:
86
- - - ~>
130
+ - - ! '>='
87
131
  - !ruby/object:Gem::Version
88
- version: '1.6'
132
+ version: '0'
89
133
  type: :development
90
134
  prerelease: false
91
- version_requirements: *70297966782300
135
+ version_requirements: *70122274570500
92
136
  - !ruby/object:Gem::Dependency
93
137
  name: rspec
94
- requirement: &70297966781840 !ruby/object:Gem::Requirement
138
+ requirement: &70122274569760 !ruby/object:Gem::Requirement
95
139
  none: false
96
140
  requirements:
97
141
  - - ~>
98
142
  - !ruby/object:Gem::Version
99
- version: '2.7'
143
+ version: '2.8'
100
144
  type: :development
101
145
  prerelease: false
102
- version_requirements: *70297966781840
146
+ version_requirements: *70122274569760
103
147
  - !ruby/object:Gem::Dependency
104
148
  name: yard
105
- requirement: &70297966781380 !ruby/object:Gem::Requirement
149
+ requirement: &70122274569120 !ruby/object:Gem::Requirement
106
150
  none: false
107
151
  requirements:
108
- - - ~>
152
+ - - ! '>='
109
153
  - !ruby/object:Gem::Version
110
- version: '0.7'
154
+ version: '0'
111
155
  type: :development
112
156
  prerelease: false
113
- version_requirements: *70297966781380
157
+ version_requirements: *70122274569120
114
158
  description: A generalized Rack framework for multiple-provider authentication.
115
159
  email:
116
160
  - michael@intridea.com
@@ -125,6 +169,7 @@ files:
125
169
  - .travis.yml
126
170
  - .yardopts
127
171
  - Gemfile
172
+ - Gemfile.rack-1.3.x
128
173
  - Guardfile
129
174
  - LICENSE
130
175
  - README.md
@@ -168,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
213
  version: 1.3.6
169
214
  requirements: []
170
215
  rubyforge_project:
171
- rubygems_version: 1.8.10
216
+ rubygems_version: 1.8.11
172
217
  signing_key:
173
218
  specification_version: 3
174
219
  summary: A generalized Rack framework for multiple-provider authentication.