omniauth-openid-2.0.1/0000755000004100000410000000000014005713775014653 5ustar www-datawww-dataomniauth-openid-2.0.1/Gemfile.lock0000644000004100000410000000352714005713775017104 0ustar www-datawww-dataGIT remote: git://github.com/mbleigh/ruby-openid.git revision: 4b6fdd152edbc9d1f617056879eb03bd82b78eb4 specs: ruby-openid (2.1.8) PATH remote: . specs: omniauth-openid (2.0.1) omniauth (>= 1.0, < 3.0) rack-openid (~> 1.4.0) GEM remote: http://rubygems.org/ specs: addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) crack (0.4.5) rexml diff-lcs (1.4.4) docile (1.3.5) hashdiff (1.0.1) hashie (4.1.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) omniauth (2.0.1) hashie (>= 3.4.6) rack (>= 1.6.2, < 3) rack-protection public_suffix (4.0.6) rack (2.2.3) rack-openid (1.4.2) rack (>= 1.1.0) ruby-openid (>= 2.1.8) rack-protection (2.1.0) rack rack-test (1.1.0) rack (>= 1.0, < 3) rake (12.3.3) rexml (3.2.4) rspec (3.10.0) rspec-core (~> 3.10.0) rspec-expectations (~> 3.10.0) rspec-mocks (~> 3.10.0) rspec-core (3.10.1) rspec-support (~> 3.10.0) rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-mocks (3.10.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.1) ruby2_keywords (0.0.4) simplecov (0.18.5) docile (~> 1.1) simplecov-html (~> 0.11) simplecov-html (0.12.3) sinatra (2.1.0) mustermann (~> 1.0) rack (~> 2.2) rack-protection (= 2.1.0) tilt (~> 2.0) tilt (2.0.10) webmock (3.11.1) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) yard (0.9.26) PLATFORMS ruby DEPENDENCIES jruby-openssl (~> 0.9) omniauth-openid! rack-test rake (~> 12.0) rspec (>= 3.0) ruby-openid (= 2.1.8)! simplecov (>= 0.9) sinatra webmock (~> 3.0) yard (>= 0.9.11) BUNDLED WITH 2.2.5 omniauth-openid-2.0.1/.travis.yml0000644000004100000410000000057214005713775016770 0ustar www-datawww-databundler_args: --without development before_install: - gem update --system - gem update bundler cache: bundler env: global: - JRUBY_OPTS="$JRUBY_OPTS --debug" language: ruby rvm: - jruby-9.2.14.0 - 2.4.10 - 2.5.8 - 2.6.6 - 2.7.2 - jruby-head - ruby-head matrix: allow_failures: - rvm: jruby-head - rvm: ruby-head fast_finish: true sudo: false omniauth-openid-2.0.1/omniauth-openid.gemspec0000644000004100000410000000156114005713775021323 0ustar www-datawww-data# encoding: utf-8 require File.expand_path('../lib/omniauth-openid/version', __FILE__) Gem::Specification.new do |gem| gem.add_dependency 'omniauth', ['>= 1.0', '< 3.0'] gem.add_dependency 'rack-openid', '~> 1.4.0' gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober', 'Tom Milewski'] gem.description = %q{OpenID strategy for OmniAuth.} gem.email = ['michael@intridea.com', 'sferik@gmail.com', 'tmilewski@gmail.com'] gem.files = `git ls-files`.split("\n") gem.homepage = 'https://github.com/intridea/omniauth-openid' gem.name = 'omniauth-openid' gem.require_paths = ['lib'] gem.license = 'MIT' gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version= gem.summary = gem.description gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") gem.version = OmniAuth::OpenID::VERSION end omniauth-openid-2.0.1/.rspec0000644000004100000410000000003214005713775015763 0ustar www-datawww-data--color --format progress omniauth-openid-2.0.1/README.md0000644000004100000410000000463514005713775016142 0ustar www-datawww-data# OmniAuth::OpenID Provides strategies for authenticating to providers using the OpenID standard. ## Installation gem install omniauth-openid ## Stand-Alone Example Use the strategy as a middleware in your application: require 'omniauth-openid' require 'openid/store/filesystem' use Rack::Session::Cookie use OmniAuth::Strategies::OpenID, :store => OpenID::Store::Filesystem.new('/tmp') 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`). A list of all OpenID stores is available at http://github.com/openid/ruby-openid/tree/master/lib/openid/store/ ## OmniAuth Builder If OpenID is one of several authentication strategies, use the OmniAuth Builder: require 'omniauth-openid' require 'openid/store/filesystem' use OmniAuth::Builder do provider :open_id, :store => OpenID::Store::Filesystem.new('/tmp') end ## Configured Identifiers You may pre-configure an OpenID identifier. For example, to use Google's main OpenID endpoint: use OmniAuth::Builder do provider :open_id, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id' end Note the use of nil, which will trigger ruby-openid's default Memory Store. ## License Copyright (c) 2011 Michael Bleigh and Intridea, Inc. 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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. omniauth-openid-2.0.1/spec/0000755000004100000410000000000014005713775015605 5ustar www-datawww-dataomniauth-openid-2.0.1/spec/omniauth/0000755000004100000410000000000014005713775017431 5ustar www-datawww-dataomniauth-openid-2.0.1/spec/omniauth/strategies/0000755000004100000410000000000014005713775021603 5ustar www-datawww-dataomniauth-openid-2.0.1/spec/omniauth/strategies/open_id_spec.rb0000644000004100000410000000666414005713775024573 0ustar www-datawww-datarequire 'spec_helper' require 'rack/openid' require 'omniauth-openid' describe OmniAuth::Strategies::OpenID, :type => :strategy do def app strat = OmniAuth::Strategies::OpenID Rack::Builder.new { use Rack::Session::Cookie, secret: 'foobar' use strat run lambda {|env| [404, {'Content-Type' => 'text/plain'}, [nil || env.key?('omniauth.auth').to_s]] } }.to_app end def expired_query_string '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' end describe '/auth/open_id without an identifier URL' do before do post '/auth/open_id' end it 'should respond with OK' do expect(last_response).to be_ok end it 'should respond with HTML' do expect(last_response.content_type).to eq 'text/html' end it 'should render an identifier URL input' do expect(last_response.body).to match %r{]*openid_url} end end # describe '/auth/open_id with an identifier URL' do # context 'successful' do # before do # @identifier_url = 'http://me.example.org' # # TODO: change this mock to actually return some sort of OpenID response # stub_request(:get, @identifier_url) # get '/auth/open_id?openid_url=' + @identifier_url # end # # it 'should redirect to the OpenID identity URL' do # last_response.should be_redirect # last_response.headers['Location'].should =~ %r{^#{@identifier_url}.*} # end # # it 'should tell the OpenID server to return to the callback URL' do # return_to = CGI.escape(last_request.url + '/callback') # last_response.headers['Location'].should =~ %r{[\?&]openid.return_to=#{return_to}} # end # end # end describe 'followed by /auth/open_id/callback' do context 'successful' do # before do # @identifier_url = 'http://me.example.org' # # TODO: change this mock to actually return some sort of OpenID response # stub_request(:get, @identifier_url) # get '/auth/open_id/callback' # end it "should set provider to open_id" it "should create auth_hash based on sreg" it "should create auth_hash based on ax" # it 'should call through to the master app' do # last_response.body.should == 'true' # end end context 'unsuccessful' do describe 'returning with expired credentials' do before do # get '/auth/open_id/callback?' + expired_query_string end it 'it should redirect to invalid credentials' do pending expect(last_response).to be_redirect expect(last_response).to match %r{invalid_credentials} end end end end end omniauth-openid-2.0.1/spec/spec_helper.rb0000644000004100000410000000060414005713775020423 0ustar www-datawww-data$:.unshift File.dirname(__FILE__) + '/../lib' require 'simplecov' SimpleCov.start require 'rspec' require 'rack/test' require 'webmock/rspec' require 'omniauth-openid' RSpec.configure do |config| config.include WebMock::API config.include Rack::Test::Methods end if OmniAuth.config.respond_to?(:request_validation_phase) OmniAuth.config.request_validation_phase = ->(env) {} end omniauth-openid-2.0.1/.gitignore0000644000004100000410000000023414005713775016642 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man /pkg rdoc spec/reports test/tmp test/version_tmp tmp omniauth-openid-2.0.1/LICENSE0000644000004100000410000000207214005713775015661 0ustar www-datawww-dataCopyright (c) 2010-2011 Michael Bleigh and Intridea, Inc. 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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. omniauth-openid-2.0.1/examples/0000755000004100000410000000000014005713775016471 5ustar www-datawww-dataomniauth-openid-2.0.1/examples/sinatra.rb0000644000004100000410000000106614005713775020462 0ustar www-datawww-datarequire 'rubygems' require 'bundler' Bundler.setup :default, :development, :example require 'sinatra' require 'omniauth-openid' require 'openid/store/filesystem' use Rack::Session::Cookie use OmniAuth::Builder do provider :open_id, store: OpenID::Store::Filesystem.new('/tmp') end get '/' do <<-HTML HTML end [:get, :post].each do |method| send method, '/auth/:provider/callback' do content_type 'text/plain' request.env['omniauth.auth'].info.to_hash.inspect end end omniauth-openid-2.0.1/.gemtest0000644000004100000410000000000014005713775016312 0ustar www-datawww-dataomniauth-openid-2.0.1/Rakefile0000644000004100000410000000023614005713775016321 0ustar www-datawww-datarequire 'bundler' Bundler::GemHelper.install_tasks require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task :default => :spec task :test => :spec omniauth-openid-2.0.1/lib/0000755000004100000410000000000014005713775015421 5ustar www-datawww-dataomniauth-openid-2.0.1/lib/omniauth/0000755000004100000410000000000014005713775017245 5ustar www-datawww-dataomniauth-openid-2.0.1/lib/omniauth/strategies/0000755000004100000410000000000014005713775021417 5ustar www-datawww-dataomniauth-openid-2.0.1/lib/omniauth/strategies/open_id.rb0000644000004100000410000001041314005713775023360 0ustar www-datawww-datarequire 'omniauth' require 'rack/openid' require 'openid/store/memory' module OmniAuth module Strategies # OmniAuth strategy for connecting via OpenID. This allows for connection # to a wide variety of sites, some of which are listed [on the OpenID website](http://openid.net/get-an-openid/). class OpenID include OmniAuth::Strategy AX = { :email => 'http://axschema.org/contact/email', :name => 'http://axschema.org/namePerson', :nickname => 'http://axschema.org/namePerson/friendly', :first_name => 'http://axschema.org/namePerson/first', :last_name => 'http://axschema.org/namePerson/last', :city => 'http://axschema.org/contact/city/home', :state => 'http://axschema.org/contact/state/home', :website => 'http://axschema.org/contact/web/default', :image => 'http://axschema.org/media/image/aspect11' } option :name, :open_id option :required, [AX[:email], AX[:name], AX[:first_name], AX[:last_name], 'email', 'fullname'] option :optional, [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname'] option :store, ::OpenID::Store::Memory.new option :identifier, nil option :identifier_param, 'openid_url' def dummy_app lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header( :identifier => identifier, :return_to => callback_url, :required => options.required, :optional => options.optional, :method => 'post' )}, []]} end def identifier i = options.identifier || request.params[options.identifier_param.to_s] i = nil if i == '' i end def request_phase identifier ? start : get_identifier end def start openid = Rack::OpenID.new(dummy_app, options[:store]) response = openid.call(env) case env['rack.openid.response'] when Rack::OpenID::MissingResponse, Rack::OpenID::TimeoutResponse fail!(:connection_failed) else response end end def get_identifier f = OmniAuth::Form.new(:title => 'OpenID Authentication') f.label_field('OpenID Identifier', options.identifier_param) f.input_field('url', options.identifier_param) f.to_response end uid { openid_response.display_identifier } info do sreg_user_info.merge(ax_user_info) end extra do {'response' => openid_response} end def callback_phase return fail!(:invalid_credentials) unless openid_response && openid_response.status == :success super end def openid_response unless @openid_response openid = Rack::OpenID.new(lambda{|env| [200,{},[]]}, options[:store]) openid.call(env) @openid_response = env.delete('rack.openid.response') end @openid_response end def sreg_user_info sreg = ::OpenID::SReg::Response.from_success_response(openid_response) return {} unless sreg { 'email' => sreg['email'], 'name' => sreg['fullname'], 'location' => sreg['postcode'], 'nickname' => sreg['nickname'] }.reject{|k,v| v.nil? || v == ''} end def ax_user_info ax = ::OpenID::AX::FetchResponse.from_success_response(openid_response) return {} unless ax { 'email' => ax.get_single(AX[:email]), 'first_name' => ax.get_single(AX[:first_name]), 'last_name' => ax.get_single(AX[:last_name]), 'name' => (ax.get_single(AX[:name]) || [ax.get_single(AX[:first_name]), ax.get_single(AX[:last_name])].join(' ')).strip, '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?), 'nickname' => ax.get_single(AX[:nickname]), 'urls' => ({'Website' => Array(ax.get_single(AX[:website])).first} if Array(ax.get_single(AX[:website])).any?) }.inject({}){|h,(k,v)| h[k] = Array(v).first; h}.reject{|k,v| v.nil? || v == ''} end end end end OmniAuth.config.add_camelization 'openid', 'OpenID' OmniAuth.config.add_camelization 'open_id', 'OpenID' omniauth-openid-2.0.1/lib/omniauth-openid.rb0000644000004100000410000000011014005713775021036 0ustar www-datawww-datarequire 'omniauth-openid/version' require 'omniauth/strategies/open_id' omniauth-openid-2.0.1/lib/omniauth-openid/0000755000004100000410000000000014005713775020521 5ustar www-datawww-dataomniauth-openid-2.0.1/lib/omniauth-openid/version.rb0000644000004100000410000000010014005713775022522 0ustar www-datawww-datamodule OmniAuth module OpenID VERSION = '2.0.1' end end omniauth-openid-2.0.1/Guardfile0000644000004100000410000000037214005713775016502 0ustar www-datawww-data# A sample Guardfile # More info at https://github.com/guard/guard#readme guard 'rspec', :version => 2 do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end omniauth-openid-2.0.1/.yardopts0000644000004100000410000000006514005713775016522 0ustar www-datawww-data--markup markdown --markup-provider maruku - LICENSE omniauth-openid-2.0.1/Gemfile0000644000004100000410000000061114005713775016144 0ustar www-datawww-datasource 'http://rubygems.org' gem 'rake', '~> 12.0' platforms :jruby do gem 'jruby-openssl', '~> 0.9' end gem 'ruby-openid', '2.1.8', :git => 'git://github.com/mbleigh/ruby-openid.git' gemspec group :development, :test do gem 'rack-test' gem 'rspec', '>= 3.0' gem 'simplecov', '>= 0.9' gem 'webmock', '~> 3.0' gem 'yard', '>= 0.9.11' end group :example do gem 'sinatra' end