omniauth-openid 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /coverage
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=nested
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --markup markdown
2
+ --markup-provider maruku
3
+ -
4
+ LICENSE
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ require File.expand_path('../lib/omniauth/version', __FILE__)
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ platforms :jruby do
6
+ gem 'jruby-openssl', '~> 0.7'
7
+ end
8
+
9
+ gem 'ruby-openid', '2.1.8', :git => 'git://github.com/mbleigh/ruby-openid.git'
10
+
11
+ gemspec
12
+
13
+ group :development, :test do
14
+ gem 'guard'
15
+ gem 'guard-rspec'
16
+ gem 'growl'
17
+ gem 'rb-fsevent'
18
+ end
19
+
20
+ group :example do
21
+ gem 'sinatra'
22
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ GIT
2
+ remote: git://github.com/mbleigh/ruby-openid.git
3
+ revision: 4b6fdd152edbc9d1f617056879eb03bd82b78eb4
4
+ specs:
5
+ ruby-openid (2.1.8)
6
+
7
+ PATH
8
+ remote: .
9
+ specs:
10
+ omniauth-openid (1.0.0.beta1)
11
+ omniauth (~> 1.0.0.beta1)
12
+ rack-openid (~> 1.3.1)
13
+
14
+ GEM
15
+ remote: http://rubygems.org/
16
+ specs:
17
+ addressable (2.2.6)
18
+ crack (0.3.1)
19
+ diff-lcs (1.1.3)
20
+ growl (1.0.3)
21
+ guard (0.8.7)
22
+ thor (~> 0.14.6)
23
+ guard-rspec (0.5.0)
24
+ guard (>= 0.8.4)
25
+ hashie (1.2.0)
26
+ multi_json (1.0.3)
27
+ omniauth (1.0.0.pr2)
28
+ hashie
29
+ rack
30
+ rack (1.3.5)
31
+ rack-openid (1.3.1)
32
+ rack (>= 1.1.0)
33
+ ruby-openid (>= 2.1.8)
34
+ rack-protection (1.1.2)
35
+ rack
36
+ rack-test (0.6.1)
37
+ rack (>= 1.0)
38
+ rake (0.9.2)
39
+ rb-fsevent (0.4.3.1)
40
+ rdiscount (1.6.8)
41
+ rspec (2.7.0)
42
+ rspec-core (~> 2.7.0)
43
+ rspec-expectations (~> 2.7.0)
44
+ rspec-mocks (~> 2.7.0)
45
+ rspec-core (2.7.0)
46
+ rspec-expectations (2.7.0)
47
+ diff-lcs (~> 1.1.2)
48
+ rspec-mocks (2.7.0)
49
+ simplecov (0.5.4)
50
+ multi_json (~> 1.0.3)
51
+ simplecov-html (~> 0.5.3)
52
+ simplecov-html (0.5.3)
53
+ sinatra (1.3.0)
54
+ rack (~> 1.3)
55
+ rack-protection (~> 1.1)
56
+ tilt (~> 1.3)
57
+ thor (0.14.6)
58
+ tilt (1.3.3)
59
+ webmock (1.7.7)
60
+ addressable (> 2.2.5, ~> 2.2)
61
+ crack (>= 0.1.7)
62
+ yard (0.7.2)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ growl
69
+ guard
70
+ guard-rspec
71
+ jruby-openssl (~> 0.7)
72
+ omniauth-openid!
73
+ rack-test (~> 0.5)
74
+ rake (~> 0.8)
75
+ rb-fsevent
76
+ rdiscount (~> 1.6)
77
+ rspec (~> 2.5)
78
+ ruby-openid (= 2.1.8)!
79
+ simplecov (~> 0.4)
80
+ sinatra
81
+ webmock (~> 1.7)
82
+ yard (~> 0.7)
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # OmniAuth::OpenID
2
+
3
+ Provides strategies for authenticating to providers using the OpenID standard.
4
+
5
+ ## Installation
6
+
7
+ To get just OpenID functionality:
8
+
9
+ gem install oa-openid
10
+
11
+ For the full auth suite:
12
+
13
+ gem install omniauth
14
+
15
+ ## Stand-Alone Example
16
+
17
+ Use the strategy as a middleware in your application:
18
+
19
+ require 'omniauth/openid'
20
+ require 'openid/store/filesystem'
21
+
22
+ use Rack::Session::Cookie
23
+ use OmniAuth::Strategies::OpenID, OpenID::Store::Filesystem.new('/tmp')
24
+
25
+ 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 `identifier` parameter to the URL (Example: `/auth/open_id?openid_url=yahoo.com`).
26
+
27
+ A list of all OpenID stores is available at http://github.com/openid/ruby-openid/tree/master/lib/openid/store/
28
+
29
+ ## OmniAuth Builder
30
+
31
+ If OpenID is one of several authentication strategies, use the OmniAuth Builder:
32
+
33
+ require 'omniauth/openid'
34
+ require 'omniauth/basic' # for Campfire
35
+ require 'openid/store/filesystem'
36
+
37
+ use OmniAuth::Builder do
38
+ provider :open_id, OpenID::Store::Filesystem.new('/tmp')
39
+ provider :campfire
40
+ end
41
+
42
+ ## Configured Identifiers
43
+
44
+ You may pre-configure an OpenID identifier. For example, to use Google's main OpenID endpoint:
45
+
46
+ use OmniAuth::Builder do
47
+ provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
48
+ end
49
+
50
+ Note the use of nil, which will trigger ruby-openid's default Memory Store.
51
+
52
+ ## License
53
+
54
+ Copyright (c) 2011 Michael Bleigh and Intridea, Inc.
55
+
56
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
6
+ task :test => :spec
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.setup :default, :development, :example
5
+ require 'sinatra'
6
+ require 'omniauth-openid'
7
+ require 'openid/store/filesystem'
8
+
9
+ use Rack::Session::Cookie
10
+
11
+ use OmniAuth::Builder do
12
+ provider :open_id, store: OpenID::Store::Filesystem.new('/tmp')
13
+ end
14
+
15
+ get '/' do
16
+ <<-HTML
17
+ <ul>
18
+ <li><a href='/auth/open_id'>Sign in with OpenID</a></li>
19
+ </ul>
20
+ HTML
21
+ end
22
+
23
+ [:get, :post].each do |method|
24
+ send method, '/auth/:provider/callback' do
25
+ content_type 'text/plain'
26
+ request.env['omniauth.auth'].info.to_hash.inspect
27
+ end
28
+ end
data/lib/oa-openid.rb ADDED
@@ -0,0 +1 @@
1
+ require 'omniauth/openid'
@@ -0,0 +1,2 @@
1
+ require 'omniauth-openid/version'
2
+ require 'omniauth/strategies/open_id'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module OpenID
3
+ VERSION = '1.0.0.beta1'
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ require 'omniauth/openid'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class GoogleApps < OmniAuth::Strategies::OpenID
6
+ def initialize(app, store = nil, options = {}, &block)
7
+ options[:name] ||= 'google_apps'
8
+ super(app, store, options, &block)
9
+ end
10
+
11
+ def get_identifier
12
+ OmniAuth::Form.build(:title => 'Google Apps Authentication') do
13
+ label_field('Google Apps Domain', 'domain')
14
+ input_field('url', 'domain')
15
+ end.to_response
16
+ end
17
+
18
+ def identifier
19
+ options[:domain] || request['domain']
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,55 @@
1
+ require 'rack/openid'
2
+ require 'omniauth/openid'
3
+ require 'oauth'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ # OmniAuth strategy for connecting to Google via the OpenID+OAuth Hybrid Protocol.
8
+ # For help, check the example implementation on https://github.com/boyvanamstel/Google-Hybrid-Omniauth-implementation
9
+ class GoogleHybrid < OmniAuth::Strategies::OpenID
10
+
11
+ protected
12
+
13
+ def dummy_app
14
+ lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header(
15
+ :identifier => identifier,
16
+ :return_to => callback_url,
17
+ :required => @options[:required],
18
+ :optional => @options[:optional],
19
+ :"oauth[consumer]" => @options[:consumer_key],
20
+ :"oauth[scope]" => @options[:scope],
21
+ :method => 'post'
22
+ )}, []]}
23
+ end
24
+
25
+ def auth_hash
26
+ # Based on https://gist.github.com/569650 by nov
27
+ oauth_response = ::OpenID::OAuth::Response.from_success_response(@openid_response)
28
+
29
+ consumer = ::OAuth::Consumer.new(
30
+ @options[:consumer_key],
31
+ @options[:consumer_secret],
32
+ :site => 'https://www.google.com',
33
+ :access_token_path => '/accounts/OAuthGetAccessToken'
34
+ )
35
+ request_token = ::OAuth::RequestToken.new(
36
+ consumer,
37
+ oauth_response.request_token,
38
+ "" # OAuth request token secret is also blank in OpenID/OAuth Hybrid
39
+ )
40
+ @access_token = request_token.get_access_token
41
+
42
+ OmniAuth::Utils.deep_merge(super(), {
43
+ 'uid' => @openid_response.display_identifier,
44
+ 'user_info' => user_info(@openid_response),
45
+ 'credentials' => {
46
+ 'scope' => @options[:scope],
47
+ 'token' => @access_token.token,
48
+ 'secret' => @access_token.secret
49
+ }
50
+ })
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,122 @@
1
+ require 'omniauth'
2
+ require 'rack/openid'
3
+ require 'openid/store/memory'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ # OmniAuth strategy for connecting via OpenID. This allows for connection
8
+ # to a wide variety of sites, some of which are listed [on the OpenID website](http://openid.net/get-an-openid/).
9
+ class OpenID
10
+ include OmniAuth::Strategy
11
+
12
+ AX = {
13
+ :email => 'http://axschema.org/contact/email',
14
+ :name => 'http://axschema.org/namePerson',
15
+ :nickname => 'http://axschema.org/namePerson/friendly',
16
+ :first_name => 'http://axschema.org/namePerson/first',
17
+ :last_name => 'http://axschema.org/namePerson/last',
18
+ :city => 'http://axschema.org/contact/city/home',
19
+ :state => 'http://axschema.org/contact/state/home',
20
+ :website => 'http://axschema.org/contact/web/default',
21
+ :image => 'http://axschema.org/media/image/aspect11'
22
+ }
23
+
24
+ option :name, :open_id
25
+ option :required, [AX[:email], AX[:name], AX[:first_name], AX[:last_name], 'email', 'fullname']
26
+ option :optional, [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname']
27
+ option :store, ::OpenID::Store::Memory.new
28
+ option :identifier, nil
29
+ option :identifier_param, 'openid_url'
30
+
31
+ def dummy_app
32
+ lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header(
33
+ :identifier => identifier,
34
+ :return_to => callback_url,
35
+ :required => options.required,
36
+ :optional => options.optional,
37
+ :method => 'post'
38
+ )}, []]}
39
+ end
40
+
41
+ def identifier
42
+ i = options.identifier || request.params[options.identifier_param.to_s]
43
+ i = nil if i == ''
44
+ i
45
+ end
46
+
47
+ def request_phase
48
+ identifier ? start : get_identifier
49
+ end
50
+
51
+ def start
52
+ openid = Rack::OpenID.new(dummy_app, options[:store])
53
+ response = openid.call(env)
54
+ case env['rack.openid.response']
55
+ when Rack::OpenID::MissingResponse, Rack::OpenID::TimeoutResponse
56
+ fail!(:connection_failed)
57
+ else
58
+ response
59
+ end
60
+ end
61
+
62
+ def get_identifier
63
+ f = OmniAuth::Form.new(:title => 'OpenID Authentication')
64
+ f.label_field('OpenID Identifier', options.identifier_param)
65
+ f.input_field('url', options.identifier_param)
66
+ f.to_response
67
+ end
68
+
69
+ uid { openid_response.display_identifier }
70
+
71
+ info do
72
+ sreg_user_info.merge(ax_user_info)
73
+ end
74
+
75
+ extra do
76
+ {'response' => openid_response}
77
+ end
78
+
79
+ def callback_phase
80
+ return fail!(:invalid_credentials) unless openid_response && openid_response.status == :success
81
+ super
82
+ end
83
+
84
+ def openid_response
85
+ unless @openid_response
86
+ openid = Rack::OpenID.new(lambda{|env| [200,{},[]]}, options[:store])
87
+ openid.call(env)
88
+ @openid_response = env.delete('rack.openid.response')
89
+ end
90
+ @openid_response
91
+ end
92
+
93
+ def sreg_user_info
94
+ sreg = ::OpenID::SReg::Response.from_success_response(openid_response)
95
+ return {} unless sreg
96
+ {
97
+ 'email' => sreg['email'],
98
+ 'name' => sreg['fullname'],
99
+ 'location' => sreg['postcode'],
100
+ 'nickname' => sreg['nickname']
101
+ }.reject{|k,v| v.nil? || v == ''}
102
+ end
103
+
104
+ def ax_user_info
105
+ ax = ::OpenID::AX::FetchResponse.from_success_response(openid_response)
106
+ return {} unless ax
107
+ {
108
+ 'email' => ax.get_single(AX[:email]),
109
+ 'first_name' => ax.get_single(AX[:first_name]),
110
+ 'last_name' => ax.get_single(AX[:last_name]),
111
+ 'name' => (ax.get_single(AX[:name]) || [ax.get_single(AX[:first_name]), ax.get_single(AX[:last_name])].join(' ')).strip,
112
+ 'location' => ("#{ax.get_single(AX[:city])}, #{ax.get_single(AX[:state])}" if Array(ax.get_single(AX[:city])).any? && Array(ax.get_single(AX[:state])).any?),
113
+ 'nickname' => ax.get_single(AX[:nickname]),
114
+ 'urls' => ({'Website' => Array(ax.get_single(AX[:website])).first} if Array(ax.get_single(AX[:website])).any?)
115
+ }.inject({}){|h,(k,v)| h[k] = Array(v).first; h}.reject{|k,v| v.nil? || v == ''}
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ OmniAuth.config.add_camelization 'openid', 'OpenID'
122
+ OmniAuth.config.add_camelization 'open_id', 'OpenID'
@@ -0,0 +1,55 @@
1
+ require 'omniauth/openid'
2
+ module OmniAuth
3
+ module Strategies
4
+ class Steam < OmniAuth::Strategies::OpenID
5
+ def initialize(app, store = nil, api_key = nil, options = {}, &block)
6
+ options[:identifier] ||= "http://steamcommunity.com/openid"
7
+ options[:name] ||= 'steam'
8
+ @api_key = api_key
9
+ super(app, store, options, &block)
10
+ end
11
+
12
+ def user_info(response=nil)
13
+ player = user_hash['response']['players']['player'].first
14
+ nickname = player["personaname"]
15
+ name = player["realname"]
16
+ url = player["profileurl"]
17
+ country = player["loccountrycode"]
18
+ state = player["locstatecode"]
19
+ city = player["loccityid"]
20
+
21
+ {
22
+ 'nickname' => nickname,
23
+ 'name' => name,
24
+ 'url' => url,
25
+ 'location' => "#{city}, #{state}, #{country}"
26
+ }
27
+ end
28
+
29
+ def user_hash
30
+ # Steam provides no information back on a openid response other than a 64bit user id
31
+ # Need to use this information and make a API call to get user information from steam.
32
+ if @api_key
33
+ unless @user_hash
34
+ uri = URI.parse("http://api.steampowered.com/")
35
+ req = Net::HTTP::Get.new("#{uri.path}ISteamUser/GetPlayerSummaries/v0001/?key=#{@api_key}&steamids=#{@openid_response.display_identifier.split("/").last}")
36
+ res = Net::HTTP.start(uri.host, uri.port) {|http|
37
+ http.request(req)
38
+ }
39
+ end
40
+ @user_hash ||= MultiJson.decode(res.body)
41
+ else
42
+ {}
43
+ end
44
+ end
45
+
46
+ def auth_hash
47
+ OmniAuth::Utils.deep_merge(super, {
48
+ 'uid' => @openid_response.display_identifier.split("/").last,
49
+ 'user_info' => user_info,
50
+ 'extra' => {'user_hash' => user_hash}
51
+ })
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module OpenID
3
+ VERSION = "1.0.0.beta1"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../lib/omniauth-openid/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+
6
+ gem.add_dependency 'omniauth', '1.0.0.beta1'
7
+ gem.add_dependency 'rack-openid', '~> 1.3.1'
8
+ gem.add_development_dependency 'rack-test', '~> 0.5'
9
+ gem.add_development_dependency 'rake', '~> 0.8'
10
+ gem.add_development_dependency 'rdiscount', '~> 1.6'
11
+ gem.add_development_dependency 'rspec', '~> 2.5'
12
+ gem.add_development_dependency 'simplecov', '~> 0.4'
13
+ gem.add_development_dependency 'webmock', '~> 1.7'
14
+ gem.add_development_dependency 'yard', '~> 0.7'
15
+
16
+ gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
17
+ gem.description = %q{OpenID strategy for OmniAuth.}
18
+ gem.email = ['michael@intridea.com', 'sferik@gmail.com']
19
+ gem.files = `git ls-files`.split("\n")
20
+ gem.homepage = 'https://github.com/intridea/omniauth-openid'
21
+ gem.name = 'omniauth-openid'
22
+ gem.require_paths = ['lib']
23
+ gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
24
+ gem.summary = gem.description
25
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+ gem.version = OmniAuth::OpenID::VERSION
27
+ end
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+ require 'rack/openid'
3
+ require 'omniauth-openid'
4
+
5
+ describe OmniAuth::Strategies::OpenID, :type => :strategy do
6
+ def app
7
+ strat = OmniAuth::Strategies::OpenID
8
+ Rack::Builder.new {
9
+ use Rack::Session::Cookie
10
+ use strat
11
+ run lambda {|env| [404, {'Content-Type' => 'text/plain'}, [nil || env.key?('omniauth.auth').to_s]] }
12
+ }.to_app
13
+ end
14
+
15
+ def expired_query_string
16
+ 'openid=consumer&janrain_nonce=2011-07-21T20%3A14%3A56ZJ8LP3T&openid.assoc_handle=%7BHMAC-SHA1%7D%7B4e284c39%7D%7B9nvQeg%3D%3D%7D&openid.claimed_id=http%3A%2F%2Flocalhost%3A1123%2Fjohn.doe%3Fopenid.success%3Dtrue&openid.identity=http%3A%2F%2Flocalhost%3A1123%2Fjohn.doe%3Fopenid.success%3Dtrue&openid.mode=id_res&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.op_endpoint=http%3A%2F%2Flocalhost%3A1123%2Fserver%2F%3Fopenid.success%3Dtrue&openid.response_nonce=2011-07-21T20%3A14%3A56Zf9gC8S&openid.return_to=http%3A%2F%2Flocalhost%3A8888%2FDevelopment%2FWordpress%2Fwp_openid%2F%3Fopenid%3Dconsumer%26janrain_nonce%3D2011-07-21T20%253A14%253A56ZJ8LP3T&openid.sig=GufV13SUJt8VgmSZ92jGZCFBEvQ%3D&openid.signed=assoc_handle%2Cclaimed_id%2Cidentity%2Cmode%2Cns%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Csigned'
17
+ end
18
+
19
+ describe '/auth/open_id without an identifier URL' do
20
+ before do
21
+ get '/auth/open_id'
22
+ end
23
+
24
+ it 'should respond with OK' do
25
+ last_response.should be_ok
26
+ end
27
+
28
+ it 'should respond with HTML' do
29
+ last_response.content_type.should == 'text/html'
30
+ end
31
+
32
+ it 'should render an identifier URL input' do
33
+ last_response.body.should =~ %r{<input[^>]*openid_url}
34
+ end
35
+ end
36
+
37
+ #describe '/auth/open_id with an identifier URL' do
38
+ # context 'successful' do
39
+ # before do
40
+ # @identifier_url = 'http://me.example.org'
41
+ # # TODO: change this mock to actually return some sort of OpenID response
42
+ # stub_request(:get, @identifier_url)
43
+ # get '/auth/open_id?openid_url=' + @identifier_url
44
+ # end
45
+ #
46
+ # it 'should redirect to the OpenID identity URL' do
47
+ # last_response.should be_redirect
48
+ # last_response.headers['Location'].should =~ %r{^#{@identifier_url}.*}
49
+ # end
50
+ #
51
+ # it 'should tell the OpenID server to return to the callback URL' do
52
+ # return_to = CGI.escape(last_request.url + '/callback')
53
+ # last_response.headers['Location'].should =~ %r{[\?&]openid.return_to=#{return_to}}
54
+ # end
55
+ # end
56
+ #end
57
+
58
+ describe 'followed by /auth/open_id/callback' do
59
+ context 'successful' do
60
+ #before do
61
+ # @identifier_url = 'http://me.example.org'
62
+ # # TODO: change this mock to actually return some sort of OpenID response
63
+ # stub_request(:get, @identifier_url)
64
+ # get '/auth/open_id/callback'
65
+ #end
66
+
67
+ it "should set provider to open_id"
68
+ it "should create auth_hash based on sreg"
69
+ it "should create auth_hash based on ax"
70
+
71
+ #it 'should call through to the master app' do
72
+ # last_response.body.should == 'true'
73
+ #end
74
+ end
75
+
76
+ context 'unsuccessful' do
77
+ describe 'returning with expired credentials' do
78
+ before do
79
+ # get '/auth/open_id/callback?' + expired_query_string
80
+ end
81
+
82
+ it 'it should redirect to invalid credentials' do
83
+ pending
84
+ last_response.should be_redirect
85
+ last_response.headers['Location'].should =~ %r{invalid_credentials}
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ end
@@ -0,0 +1,13 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../lib'
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth-openid'
9
+
10
+ RSpec.configure do |config|
11
+ config.include WebMock::API
12
+ config.include Rack::Test::Methods
13
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-openid
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.beta1
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Michael Bleigh
9
+ - Erik Michaels-Ober
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-10-26 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: omniauth
17
+ requirement: &70281189852360 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - =
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.0.beta1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70281189852360
26
+ - !ruby/object:Gem::Dependency
27
+ name: rack-openid
28
+ requirement: &70281189851840 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *70281189851840
37
+ - !ruby/object:Gem::Dependency
38
+ name: rack-test
39
+ requirement: &70281189851380 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: '0.5'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70281189851380
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: &70281189850920 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '0.8'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *70281189850920
59
+ - !ruby/object:Gem::Dependency
60
+ name: rdiscount
61
+ requirement: &70281189850460 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: '1.6'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *70281189850460
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: &70281189850000 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.5'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *70281189850000
81
+ - !ruby/object:Gem::Dependency
82
+ name: simplecov
83
+ requirement: &70281189849540 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: '0.4'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *70281189849540
92
+ - !ruby/object:Gem::Dependency
93
+ name: webmock
94
+ requirement: &70281189849080 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ version: '1.7'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *70281189849080
103
+ - !ruby/object:Gem::Dependency
104
+ name: yard
105
+ requirement: &70281189848580 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.7'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: *70281189848580
114
+ description: OpenID strategy for OmniAuth.
115
+ email:
116
+ - michael@intridea.com
117
+ - sferik@gmail.com
118
+ executables: []
119
+ extensions: []
120
+ extra_rdoc_files: []
121
+ files:
122
+ - .gemtest
123
+ - .gitignore
124
+ - .rspec
125
+ - .yardopts
126
+ - Gemfile
127
+ - Gemfile.lock
128
+ - Guardfile
129
+ - LICENSE
130
+ - README.md
131
+ - Rakefile
132
+ - examples/sinatra.rb
133
+ - lib/oa-openid.rb
134
+ - lib/omniauth-openid.rb
135
+ - lib/omniauth-openid/version.rb
136
+ - lib/omniauth/strategies/google_apps.rb
137
+ - lib/omniauth/strategies/google_hybrid.rb
138
+ - lib/omniauth/strategies/open_id.rb
139
+ - lib/omniauth/strategies/steam.rb
140
+ - lib/omniauth/version.rb
141
+ - omniauth-openid.gemspec
142
+ - spec/omniauth/strategies/open_id_spec.rb
143
+ - spec/spec_helper.rb
144
+ homepage: https://github.com/intridea/omniauth-openid
145
+ licenses: []
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ! '>'
160
+ - !ruby/object:Gem::Version
161
+ version: 1.3.1
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 1.8.10
165
+ signing_key:
166
+ specification_version: 3
167
+ summary: OpenID strategy for OmniAuth.
168
+ test_files:
169
+ - spec/omniauth/strategies/open_id_spec.rb
170
+ - spec/spec_helper.rb