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 ADDED
Binary file
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --markup markdown
2
+ --markup-provider maruku
3
+ -
4
+ LICENSE.md
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
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 [![CI Build Status](https://secure.travis-ci.org/intridea/omniauth.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/intridea/omniauth.png?travis)][gemnasium]
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
- ## License
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
- Copyright (c) 2011 Intridea, Inc.
148
-
149
- Permission is hereby granted, free of charge, to any person obtaining a
150
- copy of this software and associated documentation files (the "Software"),
151
- to deal in the Software without restriction, including without limitation
152
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
153
- and/or sell copies of the Software, and to permit persons to whom the
154
- Software is furnished to do so, subject to the following conditions:
155
-
156
- The above copyright notice and this permission notice shall be included
157
- in all copies or substantial portions of the Software.
158
-
159
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
160
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
161
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
162
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
163
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
164
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
165
- DEALINGS IN THE SOFTWARE.
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
@@ -4,7 +4,7 @@ require 'logger'
4
4
 
5
5
  module OmniAuth
6
6
  class Error < StandardError; end
7
-
7
+
8
8
  module Strategies
9
9
  autoload :Developer, 'omniauth/strategies/developer'
10
10
  end
data/lib/omniauth/form.rb CHANGED
@@ -101,7 +101,7 @@ module OmniAuth
101
101
  def self.build(options = {},&block)
102
102
  form = OmniAuth::Form.new(options)
103
103
  if block.arity > 0
104
- yield form
104
+ yield form
105
105
  else
106
106
  form.instance_eval(&block)
107
107
  end
@@ -21,7 +21,7 @@ module OmniAuth
21
21
  # @example Custom Fields
22
22
  #
23
23
  # use OmniAuth::Builder do
24
- # provider :developer,
24
+ # provider :developer,
25
25
  # :fields => [:first_name, :last_name],
26
26
  # :uid_field => :last_name
27
27
  # end
@@ -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(request.env['HTTP_X_FORWARDED_PROTO'] == 'https')
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 'should set an auth hash' do
9
- last_request.env['omniauth.auth'].should be_kind_of(Hash)
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 "should set the provider to #{provider}" do
15
- (last_request.env['omniauth.auth'] || {})['provider'].should == 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 "should set the UID to #{uid}" do
21
- (last_request.env['omniauth.auth'] || {})['uid'].should == 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 "should set the user_info to #{user_info}" do
27
- (last_request.env['omniauth.auth'] || {})['user_info'].should == 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
@@ -1,3 +1,3 @@
1
1
  module OmniAuth
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2" unless defined?(OmniAuth::VERSION)
3
3
  end
data/omniauth.gemspec CHANGED
@@ -1,27 +1,26 @@
1
- # encoding: utf-8
2
- require File.expand_path('../lib/omniauth/version', __FILE__)
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 |gem|
5
- gem.name = 'omniauth'
6
- gem.description = %q{A generalized Rack framework for multiple-provider authentication.}
7
- gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
8
- gem.email = ['michael@intridea.com', 'sferik@gmail.com']
9
-
10
- gem.add_runtime_dependency 'rack'
11
- gem.add_runtime_dependency 'hashie', '~> 1.2'
12
-
13
- gem.add_development_dependency 'maruku'
14
- gem.add_development_dependency 'simplecov'
15
- gem.add_development_dependency 'rack-test'
16
- gem.add_development_dependency 'rake'
17
- gem.add_development_dependency 'rspec', '~> 2.8'
18
- gem.add_development_dependency 'yard'
19
-
20
- gem.version = OmniAuth::VERSION
21
- gem.files = `git ls-files`.split("\n")
22
- gem.homepage = 'http://github.com/intridea/omniauth'
23
- gem.require_paths = ['lib']
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 'should convert a supplied info key into an InfoHash object' do
5
+ it "converts a supplied info key into an InfoHash object" do
6
6
  subject.info = {:first_name => 'Awesome'}
7
- subject.info.should be_kind_of(OmniAuth::AuthHash::InfoHash)
8
- subject.info.first_name.should == 'Awesome'
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 '#valid?' do
11
+ describe "#valid?" do
12
12
  subject{ OmniAuth::AuthHash.new(:uid => '123', :provider => 'example', :info => {:name => 'Steven'}) }
13
13
 
14
- it 'should be valid with the right parameters' do
15
- subject.should be_valid
14
+ it "is valid with the right parameters" do
15
+ expect(subject).to be_valid
16
16
  end
17
17
 
18
- it 'should require a uid' do
18
+ it "requires a uid" do
19
19
  subject.uid = nil
20
- subject.should_not be_valid
20
+ expect(subject).not_to be_valid
21
21
  end
22
22
 
23
- it 'should require a provider' do
23
+ it "requires a provider" do
24
24
  subject.provider = nil
25
- subject.should_not be_valid
25
+ expect(subject).not_to be_valid
26
26
  end
27
27
 
28
- it 'should require a name in the user info hash' do
28
+ it "requires a name in the user info hash" do
29
29
  subject.info.name = nil
30
- subject.should_not be_valid?
30
+ expect(subject).not_to be_valid?
31
31
  end
32
32
  end
33
33
 
34
- describe '#name' do
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 'should default to the name key' do
45
- subject.info.name.should == 'Phillip J. Fry'
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 'should fall back to go to first_name last_name concatenation' do
48
+ it "falls back to go to first_name last_name concatenation" do
49
49
  subject.info.name = nil
50
- subject.info.name.should == 'Phillip Fry'
50
+ expect(subject.info.name).to eq('Phillip Fry')
51
51
  end
52
52
 
53
- it 'should display only a first or last name if only that is available' do
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.should == 'Fry'
56
+ expect(subject.info.name).to eq('Fry')
57
57
  end
58
58
 
59
- it 'should display the nickname if no name, first, or last is available' do
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.should == 'meatbag'
62
+ expect(subject.info.name).to eq('meatbag')
63
63
  end
64
64
 
65
- it 'should display the email if no name, first, last, or nick is available' do
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.should == 'fry@planetexpress.com'
68
+ expect(subject.info.name).to eq('fry@planetexpress.com')
69
69
  end
70
70
  end
71
71
 
72
- describe '#to_hash' do
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 'should be a plain old hash' do
77
- hash.class.should == ::Hash
76
+ it "is a plain old hash" do
77
+ expect(hash.class).to eq(::Hash)
78
78
  end
79
79
 
80
- it 'should have string keys' do
81
- hash.keys.should be_include('uid')
80
+ it "has string keys" do
81
+ expect(hash.keys).to be_include('uid')
82
82
  end
83
83
 
84
- it 'should convert an info hash as well' do
84
+ it "converts an info hash as well" do
85
85
  subject.info = {:first_name => 'Bob', :last_name => 'Example'}
86
- subject.info.class.should == OmniAuth::AuthHash::InfoHash
87
- subject.to_hash['info'].class.should == ::Hash
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 'should supply the calculated name in the converted hash' do
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'].should == 'Bob Examplar'
92
+ expect(hash['info']['name']).to eq('Bob Examplar')
93
93
  end
94
94
 
95
- it 'should not pollute the URL hash with "name" etc' do
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'].should == {'Homepage' => "http://homepage.com"}
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 '#valid?' do
103
- it 'should be valid if there is a name' do
104
- OmniAuth::AuthHash::InfoHash.new(:name => 'Awesome').should be_valid
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 '#provider' do
5
- it 'should translate a symbol to a constant' do
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 'should also just accept a class' do
12
+ it "accepts a class" do
13
13
  class ::ExampleClass; end
14
14
 
15
- lambda{ OmniAuth::Builder.new(nil) do
16
- provider ::ExampleClass
17
- end }.should_not raise_error
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 "should raise a helpful LoadError message if it can't find the class" do
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 '#options' do
30
- it 'should merge provided options in' do
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 'should add an argument if no options are provided' do
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')