omniauth 1.1.1 → 1.1.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.tar.gz.sig +0 -0
- data/.yardopts +4 -0
- data/{LICENSE → LICENSE.md} +1 -1
- data/README.md +41 -27
- data/lib/omniauth.rb +1 -1
- data/lib/omniauth/form.rb +1 -1
- data/lib/omniauth/strategies/developer.rb +1 -1
- data/lib/omniauth/strategy.rb +4 -4
- data/lib/omniauth/test/strategy_macros.rb +8 -8
- data/lib/omniauth/version.rb +1 -1
- data/omniauth.gemspec +24 -25
- data/spec/omniauth/auth_hash_spec.rb +38 -38
- data/spec/omniauth/builder_spec.rb +12 -10
- data/spec/omniauth/failure_endpoint_spec.rb +13 -13
- data/spec/omniauth/form_spec.rb +10 -10
- data/spec/omniauth/strategies/developer_spec.rb +21 -21
- data/spec/omniauth/strategy_spec.rb +236 -228
- data/spec/omniauth_spec.rb +40 -40
- data/spec/spec_helper.rb +3 -0
- metadata +41 -101
- metadata.gz.sig +0 -0
- data/Gemfile +0 -17
- data/Gemfile.rack-1.3.x +0 -4
- data/Guardfile +0 -10
data.tar.gz.sig
ADDED
Binary file
|
data/.yardopts
ADDED
data/{LICENSE → LICENSE.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2010-
|
1
|
+
Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc.
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
# OmniAuth: Standardized Multi-Provider Authentication
|
1
|
+
# OmniAuth: Standardized Multi-Provider Authentication
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/omniauth.png)][gem]
|
3
|
+
[![CI Build Status](https://secure.travis-ci.org/intridea/omniauth.png?branch=master)][travis]
|
4
|
+
[![Dependency Status](https://gemnasium.com/intridea/omniauth.png?travis)][gemnasium]
|
5
|
+
[![Code Climate](https://codeclimate.com/badge.png)][codeclimate]
|
2
6
|
|
7
|
+
[gem]: https://rubygems.org/gems/omniauth
|
3
8
|
[travis]: http://travis-ci.org/intridea/omniauth
|
4
9
|
[gemnasium]: https://gemnasium.com/intridea/omniauth
|
10
|
+
[codeclimate]: https://codeclimate.com/github/intridea/omniauth
|
5
11
|
|
6
12
|
**OmniAuth 1.0 has several breaking changes from version 0.x. You can set
|
7
13
|
the dependency to `~> 0.3.2` if you do not wish to make the more difficult
|
@@ -9,7 +15,6 @@ upgrade. See [the wiki](https://github.com/intridea/omniauth/wiki/Upgrading-to-1
|
|
9
15
|
for more information.**
|
10
16
|
|
11
17
|
## An Introduction
|
12
|
-
|
13
18
|
OmniAuth is a library that standardizes multi-provider authentication for
|
14
19
|
web applications. It was created to be powerful, flexible, and do as
|
15
20
|
little as possible. Any developer can create **strategies** for OmniAuth
|
@@ -28,7 +33,6 @@ straight through. You can use it as a placeholder when you start
|
|
28
33
|
development and easily swap in other strategies later.
|
29
34
|
|
30
35
|
## Getting Started
|
31
|
-
|
32
36
|
Each OmniAuth strategy is a Rack Middleware. That means that you can use
|
33
37
|
it the same way that you use any other Rack middleware. For example, to
|
34
38
|
use the built-in Developer strategy in a Sinatra application I might do
|
@@ -63,7 +67,6 @@ You should look to the documentation for each provider you use for
|
|
63
67
|
specific initialization requirements.
|
64
68
|
|
65
69
|
## Integrating OmniAuth Into Your Application
|
66
|
-
|
67
70
|
OmniAuth is an extremely low-touch library. It is designed to be a
|
68
71
|
black box that you can send your application's users into when you need
|
69
72
|
authentication and then get information back. OmniAuth was intentionally
|
@@ -121,7 +124,6 @@ you how you want to implement the particulars of your application's
|
|
121
124
|
authentication flow.
|
122
125
|
|
123
126
|
## Logging
|
124
|
-
|
125
127
|
OmniAuth supports a configurable logger. By default, OmniAuth will log
|
126
128
|
to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
|
127
129
|
|
@@ -131,35 +133,47 @@ OmniAuth.config.logger = Rails.logger
|
|
131
133
|
```
|
132
134
|
|
133
135
|
## Resources
|
134
|
-
|
135
136
|
The [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki) has
|
136
137
|
actively maintained in-depth documentation for OmniAuth. It should be
|
137
138
|
your first stop if you are wondering about a more in-depth look at
|
138
139
|
OmniAuth, how it works, and how to use it.
|
139
140
|
|
140
141
|
## Supported Ruby Versions
|
141
|
-
|
142
142
|
OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, JRuby (1.8 mode), and Rubinius
|
143
143
|
(1.8 and 1.9 modes).
|
144
144
|
|
145
|
-
##
|
145
|
+
## Versioning
|
146
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
147
|
+
of this scheme should be reported as bugs. Specifically, if a minor or patch
|
148
|
+
version is released that breaks backward compatibility, that version should be
|
149
|
+
immediately yanked and/or a new version should be immediately released that
|
150
|
+
restores compatibility. Breaking changes to the public API will only be
|
151
|
+
introduced with new major versions. As a result of this policy, you can (and
|
152
|
+
should) specify a dependency on this gem using the [Pessimistic Version
|
153
|
+
Constraint][pvc] with two digits of precision. For example:
|
154
|
+
|
155
|
+
spec.add_dependency 'omniauth', '~> 1.0'
|
146
156
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
157
|
+
[semver]: http://semver.org/
|
158
|
+
[pvc]: http://docs.rubygems.org/read/chapter/16#page74
|
159
|
+
|
160
|
+
## License
|
161
|
+
Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc.
|
162
|
+
|
163
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
164
|
+
of this software and associated documentation files (the "Software"), to deal
|
165
|
+
in the Software without restriction, including without limitation the rights
|
166
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
167
|
+
copies of the Software, and to permit persons to whom the Software is
|
168
|
+
furnished to do so, subject to the following conditions:
|
169
|
+
|
170
|
+
The above copyright notice and this permission notice shall be included in
|
171
|
+
all copies or substantial portions of the Software.
|
172
|
+
|
173
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
174
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
175
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
176
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
177
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
178
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
179
|
+
THE SOFTWARE.
|
data/lib/omniauth.rb
CHANGED
data/lib/omniauth/form.rb
CHANGED
data/lib/omniauth/strategy.rb
CHANGED
@@ -69,7 +69,7 @@ module OmniAuth
|
|
69
69
|
# include OmniAuth::Strategy
|
70
70
|
#
|
71
71
|
# option :foo, 'bar'
|
72
|
-
# option
|
72
|
+
# option
|
73
73
|
# end
|
74
74
|
def option(name, value = nil)
|
75
75
|
default_options[name] = value
|
@@ -219,7 +219,7 @@ module OmniAuth
|
|
219
219
|
callback_phase
|
220
220
|
end
|
221
221
|
|
222
|
-
# Returns true if the environment recognizes either the
|
222
|
+
# Returns true if the environment recognizes either the
|
223
223
|
# request or callback path.
|
224
224
|
def on_auth_path?
|
225
225
|
on_request_path? || on_callback_path?
|
@@ -362,7 +362,7 @@ module OmniAuth
|
|
362
362
|
|
363
363
|
def custom_path(kind)
|
364
364
|
if options[kind].respond_to?(:call)
|
365
|
-
result = options[kind].call(env)
|
365
|
+
result = options[kind].call(env)
|
366
366
|
return nil unless result.is_a?(String)
|
367
367
|
result
|
368
368
|
else
|
@@ -405,7 +405,7 @@ module OmniAuth
|
|
405
405
|
uri.path = ''
|
406
406
|
uri.query = nil
|
407
407
|
#sometimes the url is actually showing http inside rails because the other layers (like nginx) have handled the ssl termination.
|
408
|
-
uri.scheme = 'https' if
|
408
|
+
uri.scheme = 'https' if request.ssl?
|
409
409
|
uri.to_s
|
410
410
|
end
|
411
411
|
end
|
@@ -5,26 +5,26 @@ module OmniAuth
|
|
5
5
|
module StrategyMacros
|
6
6
|
|
7
7
|
def sets_an_auth_hash
|
8
|
-
it
|
9
|
-
last_request.env['omniauth.auth'].
|
8
|
+
it "sets an auth hash" do
|
9
|
+
expect(last_request.env['omniauth.auth']).to be_kind_of(Hash)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def sets_provider_to(provider)
|
14
|
-
it "
|
15
|
-
(last_request.env['omniauth.auth'] || {})['provider'].
|
14
|
+
it "sets the provider to #{provider}" do
|
15
|
+
expect((last_request.env['omniauth.auth'] || {})['provider']).to eq provider
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def sets_uid_to(uid)
|
20
|
-
it "
|
21
|
-
(last_request.env['omniauth.auth'] || {})['uid'].
|
20
|
+
it "sets the UID to #{uid}" do
|
21
|
+
expect((last_request.env['omniauth.auth'] || {})['uid']).to eq uid
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def sets_user_info_to(user_info)
|
26
|
-
it "
|
27
|
-
(last_request.env['omniauth.auth'] || {})['user_info'].
|
26
|
+
it "sets the user_info to #{user_info}" do
|
27
|
+
expect((last_request.env['omniauth.auth'] || {})['user_info']).to eq user_info
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/omniauth/version.rb
CHANGED
data/omniauth.gemspec
CHANGED
@@ -1,27 +1,26 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/version'
|
3
5
|
|
4
|
-
Gem::Specification.new do |
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
gem.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
|
25
|
-
gem.summary = gem.description
|
26
|
-
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.add_dependency 'hashie', '~> 1.2'
|
8
|
+
spec.add_dependency 'rack'
|
9
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
10
|
+
spec.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
|
11
|
+
spec.cert_chain = ['certs/sferik.pem']
|
12
|
+
spec.description = %q{A generalized Rack framework for multiple-provider authentication.}
|
13
|
+
spec.email = ['michael@intridea.com', 'sferik@gmail.com']
|
14
|
+
spec.files = %w(.yardopts LICENSE.md README.md Rakefile omniauth.gemspec)
|
15
|
+
spec.files += Dir.glob("lib/**/*.rb")
|
16
|
+
spec.files += Dir.glob("spec/**/*")
|
17
|
+
spec.homepage = 'http://github.com/intridea/omniauth'
|
18
|
+
spec.licenses = ['MIT']
|
19
|
+
spec.name = 'omniauth'
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
spec.required_rubygems_version = '>= 1.3.6'
|
22
|
+
spec.signing_key = File.expand_path("~/.gem/private_key.pem") if $0 =~ /gem\z/
|
23
|
+
spec.summary = spec.description
|
24
|
+
spec.test_files = Dir.glob("spec/**/*")
|
25
|
+
spec.version = OmniAuth::VERSION
|
27
26
|
end
|
@@ -2,36 +2,36 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe OmniAuth::AuthHash do
|
4
4
|
subject{ OmniAuth::AuthHash.new }
|
5
|
-
it
|
5
|
+
it "converts a supplied info key into an InfoHash object" do
|
6
6
|
subject.info = {:first_name => 'Awesome'}
|
7
|
-
subject.info.
|
8
|
-
subject.info.first_name.
|
7
|
+
expect(subject.info).to be_kind_of(OmniAuth::AuthHash::InfoHash)
|
8
|
+
expect(subject.info.first_name).to eq('Awesome')
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe "#valid?" do
|
12
12
|
subject{ OmniAuth::AuthHash.new(:uid => '123', :provider => 'example', :info => {:name => 'Steven'}) }
|
13
13
|
|
14
|
-
it
|
15
|
-
subject.
|
14
|
+
it "is valid with the right parameters" do
|
15
|
+
expect(subject).to be_valid
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it "requires a uid" do
|
19
19
|
subject.uid = nil
|
20
|
-
subject.
|
20
|
+
expect(subject).not_to be_valid
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it "requires a provider" do
|
24
24
|
subject.provider = nil
|
25
|
-
subject.
|
25
|
+
expect(subject).not_to be_valid
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it "requires a name in the user info hash" do
|
29
29
|
subject.info.name = nil
|
30
|
-
subject.
|
30
|
+
expect(subject).not_to be_valid?
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
34
|
+
describe "#name" do
|
35
35
|
subject{ OmniAuth::AuthHash.new(
|
36
36
|
:info => {
|
37
37
|
:name => 'Phillip J. Fry',
|
@@ -41,67 +41,67 @@ describe OmniAuth::AuthHash do
|
|
41
41
|
:email => 'fry@planetexpress.com'
|
42
42
|
})}
|
43
43
|
|
44
|
-
it
|
45
|
-
subject.info.name.
|
44
|
+
it "defaults to the name key" do
|
45
|
+
expect(subject.info.name).to eq('Phillip J. Fry')
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it "falls back to go to first_name last_name concatenation" do
|
49
49
|
subject.info.name = nil
|
50
|
-
subject.info.name.
|
50
|
+
expect(subject.info.name).to eq('Phillip Fry')
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
53
|
+
it "displays only a first or last name if only that is available" do
|
54
54
|
subject.info.name = nil
|
55
55
|
subject.info.first_name = nil
|
56
|
-
subject.info.name.
|
56
|
+
expect(subject.info.name).to eq('Fry')
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it "displays the nickname if no name, first, or last is available" do
|
60
60
|
subject.info.name = nil
|
61
61
|
%w(first_name last_name).each{|k| subject.info[k] = nil}
|
62
|
-
subject.info.name.
|
62
|
+
expect(subject.info.name).to eq('meatbag')
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
65
|
+
it "displays the email if no name, first, last, or nick is available" do
|
66
66
|
subject.info.name = nil
|
67
67
|
%w(first_name last_name nickname).each{|k| subject.info[k] = nil}
|
68
|
-
subject.info.name.
|
68
|
+
expect(subject.info.name).to eq('fry@planetexpress.com')
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
describe
|
72
|
+
describe "#to_hash" do
|
73
73
|
subject{ OmniAuth::AuthHash.new(:uid => '123', :provider => 'test', :name => 'Bob Example')}
|
74
74
|
let(:hash){ subject.to_hash }
|
75
75
|
|
76
|
-
it
|
77
|
-
hash.class.
|
76
|
+
it "is a plain old hash" do
|
77
|
+
expect(hash.class).to eq(::Hash)
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
hash.keys.
|
80
|
+
it "has string keys" do
|
81
|
+
expect(hash.keys).to be_include('uid')
|
82
82
|
end
|
83
83
|
|
84
|
-
it
|
84
|
+
it "converts an info hash as well" do
|
85
85
|
subject.info = {:first_name => 'Bob', :last_name => 'Example'}
|
86
|
-
subject.info.class.
|
87
|
-
subject.to_hash['info'].class.
|
86
|
+
expect(subject.info.class).to eq(OmniAuth::AuthHash::InfoHash)
|
87
|
+
expect(subject.to_hash['info'].class).to eq(::Hash)
|
88
88
|
end
|
89
89
|
|
90
|
-
it
|
90
|
+
it "supplies the calculated name in the converted hash" do
|
91
91
|
subject.info = {:first_name => 'Bob', :last_name => 'Examplar'}
|
92
|
-
hash['info']['name'].
|
92
|
+
expect(hash['info']['name']).to eq('Bob Examplar')
|
93
93
|
end
|
94
94
|
|
95
|
-
it
|
95
|
+
it "does not pollute the URL hash with 'name' etc" do
|
96
96
|
subject.info = {'urls' => {'Homepage' => "http://homepage.com"}}
|
97
|
-
subject.to_hash['info']['urls'].
|
97
|
+
expect(subject.to_hash['info']['urls']).to eq({'Homepage' => "http://homepage.com"})
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
describe OmniAuth::AuthHash::InfoHash do
|
102
|
-
describe
|
103
|
-
it
|
104
|
-
OmniAuth::AuthHash::InfoHash.new(:name => 'Awesome').
|
102
|
+
describe "#valid?" do
|
103
|
+
it "is valid if there is a name" do
|
104
|
+
expect(OmniAuth::AuthHash::InfoHash.new(:name => 'Awesome')).to be_valid
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -1,23 +1,25 @@
|
|
1
1
|
require File.expand_path('../../spec_helper', __FILE__)
|
2
2
|
|
3
3
|
describe OmniAuth::Builder do
|
4
|
-
describe
|
5
|
-
it
|
4
|
+
describe "#provider" do
|
5
|
+
it "translates a symbol to a constant" do
|
6
6
|
OmniAuth::Strategies.should_receive(:const_get).with('MyStrategy').and_return(Class.new)
|
7
7
|
OmniAuth::Builder.new(nil) do
|
8
8
|
provider :my_strategy
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it "accepts a class" do
|
13
13
|
class ::ExampleClass; end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
expect{
|
16
|
+
OmniAuth::Builder.new(nil) do
|
17
|
+
provider ::ExampleClass
|
18
|
+
end
|
19
|
+
}.not_to raise_error
|
18
20
|
end
|
19
21
|
|
20
|
-
it "
|
22
|
+
it "raises a helpful LoadError message if it can't find the class" do
|
21
23
|
expect {
|
22
24
|
OmniAuth::Builder.new(nil) do
|
23
25
|
provider :lorax
|
@@ -26,8 +28,8 @@ describe OmniAuth::Builder do
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
describe
|
30
|
-
it
|
31
|
+
describe "#options" do
|
32
|
+
it "merges provided options in" do
|
31
33
|
k = Class.new
|
32
34
|
b = OmniAuth::Builder.new(nil)
|
33
35
|
b.should_receive(:use).with(k, :foo => 'bar', :baz => 'tik')
|
@@ -36,7 +38,7 @@ describe OmniAuth::Builder do
|
|
36
38
|
b.provider k, :baz => 'tik'
|
37
39
|
end
|
38
40
|
|
39
|
-
it
|
41
|
+
it "adds an argument if no options are provided" do
|
40
42
|
k = Class.new
|
41
43
|
b = OmniAuth::Builder.new(nil)
|
42
44
|
b.should_receive(:use).with(k, :foo => 'bar')
|