oa-openid 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,56 +2,56 @@ require 'omniauth/core'
2
2
 
3
3
  module OmniAuth
4
4
  # OmniAuth::OpenID provides strategies for authenticating to providers
5
- # using the OpenID standard.
6
- #
5
+ # using the OpenID standard.
6
+ #
7
7
  # # Installation
8
- #
8
+ #
9
9
  # To get just OpenID functionality:
10
- #
10
+ #
11
11
  # gem install oa-openid
12
- #
12
+ #
13
13
  # For the full auth suite:
14
- #
14
+ #
15
15
  # gem install omniauth
16
- #
16
+ #
17
17
  # # Stand-Alone Example
18
- #
18
+ #
19
19
  # Use the strategy as a middleware in your application:
20
- #
20
+ #
21
21
  # require 'omniauth/openid'
22
22
  # require 'openid/store/filesystem'
23
- #
23
+ #
24
24
  # use Rack::Session::Cookie
25
25
  # use OmniAuth::Strategies::OpenID, OpenID::Store::Filesystem.new('/tmp')
26
- #
26
+ #
27
27
  # Then simply direct users to '/auth/open_id' to prompt them for their OpenID identifier. You may also pre-set the identifier by passing an <tt>identifier</tt> parameter to the URL (Example: <tt>/auth/open_id?openid_url=yahoo.com</tt>).
28
- #
28
+ #
29
29
  # A list of all OpenID stores is available at http://github.com/openid/ruby-openid/tree/master/lib/openid/store/
30
- #
30
+ #
31
31
  # # OmniAuth Builder
32
- #
32
+ #
33
33
  # If OpenID is one of several authentication strategies, use the OmniAuth Builder:
34
- #
34
+ #
35
35
  # require 'omniauth/openid'
36
36
  # require 'omniauth/basic' # for Campfire
37
37
  # require 'openid/store/filesystem'
38
- #
38
+ #
39
39
  # use OmniAuth::Builder do
40
40
  # provider :open_id, OpenID::Store::Filesystem.new('/tmp')
41
41
  # provider :campfire
42
42
  # end
43
- #
43
+ #
44
44
  # # Configured Identifiers
45
- #
45
+ #
46
46
  # You may pre-configure an OpenID identifier. For example, to use Google's main OpenID endpoint:
47
- #
47
+ #
48
48
  # use OmniAuth::Builder do
49
49
  # provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
50
50
  # end
51
- #
51
+ #
52
52
  # Note the use of nil, which will trigger ruby-openid's default Memory Store.
53
53
  module OpenID; end
54
-
54
+
55
55
  module Strategies
56
56
  autoload :OpenID, 'omniauth/strategies/open_id'
57
57
  autoload :GoogleApps, 'omniauth/strategies/google_apps'
@@ -8,25 +8,25 @@ module OpenID
8
8
  # with others.
9
9
  def self.discover(uri)
10
10
  discovered = self.default_discover(uri)
11
-
11
+
12
12
  if discovered.last.empty?
13
- info = discover_google_apps(uri)
13
+ info = discover_google_apps(uri)
14
14
  return info if info
15
15
  end
16
-
16
+
17
17
  return discovered
18
18
  rescue OpenID::DiscoveryFailure => e
19
19
  info = discover_google_apps(uri)
20
-
20
+
21
21
  if info.nil?
22
22
  raise e
23
23
  else
24
24
  return info
25
25
  end
26
26
  end
27
-
27
+
28
28
  def self.discover_google_apps(uri)
29
29
  discovery = GoogleDiscovery.new
30
30
  discovery.perform_discovery(uri)
31
31
  end
32
- end
32
+ end
@@ -7,14 +7,14 @@ module OmniAuth
7
7
  options[:name] ||= 'google_apps'
8
8
  super(app, store, options, &block)
9
9
  end
10
-
10
+
11
11
  def get_identifier
12
12
  OmniAuth::Form.build(:title => 'Google Apps Authentication') do
13
13
  label_field('Google Apps Domain', 'domain')
14
14
  input_field('url', 'domain')
15
15
  end.to_response
16
16
  end
17
-
17
+
18
18
  def identifier
19
19
  options[:domain] || request['domain']
20
20
  end
@@ -8,11 +8,11 @@ module OmniAuth
8
8
  # to a wide variety of sites, some of which are listed [on the OpenID website](http://openid.net/get-an-openid/).
9
9
  class OpenID
10
10
  include OmniAuth::Strategy
11
-
11
+
12
12
  attr_accessor :options
13
-
13
+
14
14
  IDENTIFIER_URL_PARAMETER = 'openid_url'
15
-
15
+
16
16
  AX = {
17
17
  :email => 'http://axschema.org/contact/email',
18
18
  :name => 'http://axschema.org/namePerson',
@@ -24,13 +24,13 @@ module OmniAuth
24
24
  :website => 'http://axschema.org/contact/web/default',
25
25
  :image => 'http://axschema.org/media/image/aspect11'
26
26
  }
27
-
27
+
28
28
  # Initialize the strategy as a Rack Middleware.
29
29
  #
30
30
  # @param app [Rack Application] Standard Rack middleware application argument.
31
31
  # @param store [OpenID Store] The [OpenID Store](http://github.com/openid/ruby-openid/tree/master/lib/openid/store/)
32
32
  # you wish to use. Defaults to OpenID::MemoryStore.
33
- # @option options [Array] :required The identity fields that are required for the OpenID
33
+ # @option options [Array] :required The identity fields that are required for the OpenID
34
34
  # request. May be an ActiveExchange schema URL or an sreg identifier.
35
35
  # @option options [Array] :optional The optional attributes for the OpenID request. May
36
36
  # be ActiveExchange or sreg.
@@ -42,9 +42,9 @@ module OmniAuth
42
42
  @options[:optional] ||= [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname']
43
43
  @store = store
44
44
  end
45
-
45
+
46
46
  protected
47
-
47
+
48
48
  def dummy_app
49
49
  lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header(
50
50
  :identifier => identifier,
@@ -54,15 +54,15 @@ module OmniAuth
54
54
  :method => 'post'
55
55
  )}, []]}
56
56
  end
57
-
57
+
58
58
  def identifier
59
59
  options[:identifier] || request[IDENTIFIER_URL_PARAMETER]
60
60
  end
61
-
61
+
62
62
  def request_phase
63
63
  identifier ? start : get_identifier
64
64
  end
65
-
65
+
66
66
  def start
67
67
  openid = Rack::OpenID.new(dummy_app, @store)
68
68
  response = openid.call(env)
@@ -73,14 +73,14 @@ module OmniAuth
73
73
  response
74
74
  end
75
75
  end
76
-
76
+
77
77
  def get_identifier
78
78
  OmniAuth::Form.build(:title => 'OpenID Authentication') do
79
79
  label_field('OpenID Identifier', IDENTIFIER_URL_PARAMETER)
80
80
  input_field('url', IDENTIFIER_URL_PARAMETER)
81
81
  end.to_response
82
82
  end
83
-
83
+
84
84
  def callback_phase
85
85
  openid = Rack::OpenID.new(lambda{|env| [200,{},[]]}, @store)
86
86
  openid.call(env)
@@ -91,18 +91,18 @@ module OmniAuth
91
91
  fail!(:invalid_credentials)
92
92
  end
93
93
  end
94
-
94
+
95
95
  def auth_hash
96
96
  OmniAuth::Utils.deep_merge(super(), {
97
97
  'uid' => @openid_response.display_identifier,
98
98
  'user_info' => user_info(@openid_response)
99
99
  })
100
100
  end
101
-
101
+
102
102
  def user_info(response)
103
103
  sreg_user_info(response).merge(ax_user_info(response))
104
104
  end
105
-
105
+
106
106
  def sreg_user_info(response)
107
107
  sreg = ::OpenID::SReg::Response.from_success_response(response)
108
108
  return {} unless sreg
@@ -113,7 +113,7 @@ module OmniAuth
113
113
  'nickname' => sreg['nickname']
114
114
  }.reject{|k,v| v.nil? || v == ''}
115
115
  end
116
-
116
+
117
117
  def ax_user_info(response)
118
118
  ax = ::OpenID::AX::FetchResponse.from_success_response(response)
119
119
  return {} unless ax
@@ -0,0 +1,19 @@
1
+ module OmniAuth
2
+ module Version
3
+ unless defined?(::OmniAuth::Version::MAJOR)
4
+ MAJOR = 0
5
+ end
6
+ unless defined?(::OmniAuth::Version::MINOR)
7
+ MINOR = 2
8
+ end
9
+ unless defined?(::OmniAuth::Version::PATCH)
10
+ PATCH = 5
11
+ end
12
+ unless defined?(::OmniAuth::Version::PRE)
13
+ PRE = nil
14
+ end
15
+ unless defined?(::OmniAuth::Version::STRING)
16
+ STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
17
+ end
18
+ end
19
+ end
@@ -1,19 +1,23 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../../omniauth/lib/omniauth/version', __FILE__)
2
+ require File.expand_path('../lib/omniauth/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_dependency 'oa-core', Omniauth::VERSION.dup
6
- gem.add_dependency 'rack-openid', '~> 1.2.0'
7
- gem.add_dependency 'ruby-openid-apps-discovery'
5
+ gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
6
+ gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
7
+ gem.add_runtime_dependency 'rack-openid', '~> 1.3.1'
8
+ gem.add_runtime_dependency 'ruby-openid-apps-discovery', '~> 1.2.0'
9
+ gem.add_development_dependency 'maruku', '~> 0.6'
8
10
  gem.add_development_dependency 'rack-test', '~> 0.5'
9
11
  gem.add_development_dependency 'rake', '~> 0.8'
10
12
  gem.add_development_dependency 'rspec', '~> 2.5'
13
+ gem.add_development_dependency 'simplecov', '~> 0.4'
11
14
  gem.add_development_dependency 'webmock', '~> 1.6'
12
15
  gem.add_development_dependency 'yard', '~> 0.6'
16
+ gem.add_development_dependency 'ZenTest', '~> 4.5'
13
17
  gem.name = 'oa-openid'
14
- gem.version = Omniauth::VERSION.dup
15
- gem.summary = %q{OpenID strategies for OmniAuth.}
18
+ gem.version = OmniAuth::Version::STRING
16
19
  gem.description = %q{OpenID strategies for OmniAuth.}
20
+ gem.summary = gem.description
17
21
  gem.email = ['michael@intridea.com', 'sferik@gmail.com']
18
22
  gem.homepage = 'http://github.com/intridea/omniauth'
19
23
  gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
@@ -1,37 +1,37 @@
1
- require 'spec_helper'
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Strategies::OpenID do
4
4
 
5
5
  end
6
6
 
7
7
  # require File.dirname(__FILE__) + '/../../spec_helper'
8
- #
8
+ #
9
9
  # describe OmniAuth::Strategies::OpenID, :type => :strategy do
10
- #
10
+ #
11
11
  # include OmniAuth::Test::StrategyTestCase
12
- #
12
+ #
13
13
  # def strategy
14
14
  # [OmniAuth::Strategies::OpenID]
15
15
  # end
16
- #
16
+ #
17
17
  # describe '/auth/open_id without an identifier URL' do
18
18
  # before do
19
19
  # get '/auth/open_id'
20
20
  # end
21
- #
21
+ #
22
22
  # it 'should respond with OK' do
23
23
  # last_response.should be_ok
24
24
  # end
25
- #
25
+ #
26
26
  # it 'should respond with HTML' do
27
27
  # last_response.content_type.should == 'text/html'
28
28
  # end
29
- #
29
+ #
30
30
  # it 'should render an identifier URL input' do
31
31
  # last_response.body.should =~ %r{<input[^>]*#{OmniAuth::Strategies::OpenID::IDENTIFIER_URL_PARAMETER}}
32
32
  # end
33
33
  # end
34
- #
34
+ #
35
35
  # describe '/auth/open_id with an identifier URL' do
36
36
  # before do
37
37
  # @identifier_url = 'http://me.example.org'
@@ -39,19 +39,19 @@ end
39
39
  # stub_request(:get, @identifier_url)
40
40
  # get '/auth/open_id?openid_url=' + @identifier_url
41
41
  # end
42
- #
42
+ #
43
43
  # it 'should redirect to the OpenID identity URL' do
44
44
  # last_response.should be_redirect
45
45
  # last_response.headers['Location'].should =~ %r{^#{@identifier_url}.*}
46
46
  # end
47
- #
47
+ #
48
48
  # it 'should tell the OpenID server to return to the callback URL' do
49
49
  # return_to = CGI.escape(last_request.url + '/callback')
50
50
  # last_response.headers['Location'].should =~ %r{[\?&]openid.return_to=#{return_to}}
51
51
  # end
52
- #
52
+ #
53
53
  # end
54
- #
54
+ #
55
55
  # describe 'followed by /auth/open_id/callback' do
56
56
  # before do
57
57
  # @identifier_url = 'http://me.example.org'
@@ -59,11 +59,11 @@ end
59
59
  # stub_request(:get, @identifier_url)
60
60
  # get '/auth/open_id/callback'
61
61
  # end
62
- #
62
+ #
63
63
  # sets_an_auth_hash
64
64
  # sets_provider_to 'open_id'
65
65
  # sets_uid_to 'http://me.example.org'
66
- #
66
+ #
67
67
  # it 'should call through to the master app' do
68
68
  # last_response.body.should == 'true'
69
69
  # end
@@ -1,10 +1,8 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup
1
+ require 'simplecov'
2
+ SimpleCov.start
4
3
  require 'rspec'
5
- require 'rspec/autorun'
6
- require 'webmock/rspec'
7
4
  require 'rack/test'
5
+ require 'webmock/rspec'
8
6
  require 'omniauth/core'
9
7
  require 'omniauth/test'
10
8
  require 'omniauth/openid'
@@ -14,5 +12,3 @@ RSpec.configure do |config|
14
12
  config.include Rack::Test::Methods
15
13
  config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
16
14
  end
17
-
18
- WebMock.disable_net_connect!
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oa-openid
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.4
5
+ version: 0.2.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Bleigh
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-22 00:00:00 Z
14
+ date: 2011-04-29 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: oa-core
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - "="
23
23
  - !ruby/object:Gem::Version
24
- version: 0.2.4
24
+ version: 0.2.5
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirements:
33
33
  - - ~>
34
34
  - !ruby/object:Gem::Version
35
- version: 1.2.0
35
+ version: 1.3.1
36
36
  type: :runtime
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
@@ -41,66 +41,99 @@ dependencies:
41
41
  requirement: &id003 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
- - - ">="
44
+ - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: "0"
46
+ version: 1.2.0
47
47
  type: :runtime
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
- name: rack-test
50
+ name: maruku
51
51
  prerelease: false
52
52
  requirement: &id004 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ~>
56
56
  - !ruby/object:Gem::Version
57
- version: "0.5"
57
+ version: "0.6"
58
58
  type: :development
59
59
  version_requirements: *id004
60
60
  - !ruby/object:Gem::Dependency
61
- name: rake
61
+ name: rack-test
62
62
  prerelease: false
63
63
  requirement: &id005 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: "0.8"
68
+ version: "0.5"
69
69
  type: :development
70
70
  version_requirements: *id005
71
71
  - !ruby/object:Gem::Dependency
72
- name: rspec
72
+ name: rake
73
73
  prerelease: false
74
74
  requirement: &id006 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ~>
78
78
  - !ruby/object:Gem::Version
79
- version: "2.5"
79
+ version: "0.8"
80
80
  type: :development
81
81
  version_requirements: *id006
82
82
  - !ruby/object:Gem::Dependency
83
- name: webmock
83
+ name: rspec
84
84
  prerelease: false
85
85
  requirement: &id007 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ~>
89
89
  - !ruby/object:Gem::Version
90
- version: "1.6"
90
+ version: "2.5"
91
91
  type: :development
92
92
  version_requirements: *id007
93
93
  - !ruby/object:Gem::Dependency
94
- name: yard
94
+ name: simplecov
95
95
  prerelease: false
96
96
  requirement: &id008 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: "0.6"
101
+ version: "0.4"
102
102
  type: :development
103
103
  version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: webmock
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: "1.6"
113
+ type: :development
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: yard
117
+ prerelease: false
118
+ requirement: &id010 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ~>
122
+ - !ruby/object:Gem::Version
123
+ version: "0.6"
124
+ type: :development
125
+ version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: ZenTest
128
+ prerelease: false
129
+ requirement: &id011 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ~>
133
+ - !ruby/object:Gem::Version
134
+ version: "4.5"
135
+ type: :development
136
+ version_requirements: *id011
104
137
  description: OpenID strategies for OmniAuth.
105
138
  email:
106
139
  - michael@intridea.com
@@ -115,7 +148,6 @@ files:
115
148
  - .gemtest
116
149
  - .rspec
117
150
  - .yardopts
118
- - Gemfile
119
151
  - LICENSE
120
152
  - README.rdoc
121
153
  - Rakefile
@@ -124,6 +156,7 @@ files:
124
156
  - lib/omniauth/openid/gapps.rb
125
157
  - lib/omniauth/strategies/google_apps.rb
126
158
  - lib/omniauth/strategies/open_id.rb
159
+ - lib/omniauth/version.rb
127
160
  - oa-openid.gemspec
128
161
  - spec/omniauth/strategies/open_id_spec.rb
129
162
  - spec/spec_helper.rb
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec