omniauth 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.
Potentially problematic release.
This version of omniauth might be problematic. Click here for more details.
- data/.autotest +9 -0
- data/.document +5 -0
- data/.gitignore +36 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/.yardopts +4 -0
- data/Gemfile +6 -1
- data/README.markdown +121 -0
- data/Rakefile +50 -2
- data/lib/omniauth/version.rb +18 -4
- data/oa-basic/.gemtest +0 -0
- data/oa-basic/.rspec +3 -0
- data/oa-basic/.yardopts +4 -0
- data/oa-basic/LICENSE +19 -0
- data/oa-basic/README.rdoc +34 -0
- data/oa-basic/Rakefile +6 -0
- data/oa-basic/lib/oa-basic.rb +1 -0
- data/oa-basic/lib/omniauth/basic.rb +8 -0
- data/oa-basic/lib/omniauth/strategies/http_basic.rb +56 -0
- data/oa-basic/lib/omniauth/version.rb +19 -0
- data/oa-basic/oa-basic.gemspec +28 -0
- data/oa-basic/spec/omniauth/strategies/basic_spec.rb +7 -0
- data/oa-basic/spec/spec_helper.rb +11 -0
- data/oa-core/.gemtest +0 -0
- data/oa-core/.rspec +3 -0
- data/oa-core/.yardopts +4 -0
- data/oa-core/LICENSE +19 -0
- data/oa-core/Rakefile +6 -0
- data/oa-core/autotest/discover.rb +1 -0
- data/oa-core/lib/oa-core.rb +1 -0
- data/oa-core/lib/omniauth/builder.rb +33 -0
- data/oa-core/lib/omniauth/core.rb +135 -0
- data/oa-core/lib/omniauth/form.rb +184 -0
- data/oa-core/lib/omniauth/strategy.rb +227 -0
- data/oa-core/lib/omniauth/test.rb +12 -0
- data/oa-core/lib/omniauth/test/phony_session.rb +8 -0
- data/oa-core/lib/omniauth/test/strategy_macros.rb +34 -0
- data/oa-core/lib/omniauth/test/strategy_test_case.rb +49 -0
- data/oa-core/lib/omniauth/version.rb +19 -0
- data/oa-core/oa-core.gemspec +24 -0
- data/oa-core/spec/omniauth/builder_spec.rb +20 -0
- data/oa-core/spec/omniauth/core_spec.rb +79 -0
- data/oa-core/spec/omniauth/strategy_spec.rb +358 -0
- data/oa-core/spec/spec_helper.rb +12 -0
- data/oa-enterprise/.gemtest +0 -0
- data/oa-enterprise/.rspec +3 -0
- data/oa-enterprise/.yardopts +4 -0
- data/oa-enterprise/LICENSE +19 -0
- data/oa-enterprise/README.rdoc +82 -0
- data/oa-enterprise/Rakefile +6 -0
- data/oa-enterprise/lib/oa-enterprise.rb +1 -0
- data/oa-enterprise/lib/omniauth/enterprise.rb +8 -0
- data/oa-enterprise/lib/omniauth/strategies/cas.rb +47 -0
- data/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +98 -0
- data/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +84 -0
- data/oa-enterprise/lib/omniauth/strategies/ldap.rb +111 -0
- data/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +279 -0
- data/oa-enterprise/lib/omniauth/version.rb +19 -0
- data/oa-enterprise/oa-enterprise.gemspec +32 -0
- data/oa-enterprise/spec/fixtures/cas_failure.xml +4 -0
- data/oa-enterprise/spec/fixtures/cas_success.xml +8 -0
- data/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +94 -0
- data/oa-enterprise/spec/spec_helper.rb +14 -0
- data/oa-more/.gemtest +0 -0
- data/oa-more/.rspec +3 -0
- data/oa-more/.yardopts +4 -0
- data/oa-more/LICENSE +19 -0
- data/oa-more/README.rdoc +22 -0
- data/oa-more/Rakefile +6 -0
- data/oa-more/lib/oa-more.rb +1 -0
- data/oa-more/lib/omniauth/more.rb +9 -0
- data/oa-more/lib/omniauth/strategies/flickr.rb +86 -0
- data/oa-more/lib/omniauth/strategies/windows_live.rb +39 -0
- data/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +1143 -0
- data/oa-more/lib/omniauth/strategies/yupoo.rb +67 -0
- data/oa-more/lib/omniauth/version.rb +19 -0
- data/oa-more/oa-more.gemspec +30 -0
- data/oa-more/spec/omniauth/strategies/flickr_spec.rb +7 -0
- data/oa-more/spec/spec_helper.rb +11 -0
- data/oa-oauth/.gemtest +0 -0
- data/oa-oauth/.rspec +3 -0
- data/oa-oauth/.yardopts +4 -0
- data/oa-oauth/LICENSE +19 -0
- data/oa-oauth/README.rdoc +35 -0
- data/oa-oauth/Rakefile +6 -0
- data/oa-oauth/autotest/discover.rb +1 -0
- data/oa-oauth/lib/oa-oauth.rb +1 -0
- data/oa-oauth/lib/omniauth/oauth.rb +53 -0
- data/oa-oauth/lib/omniauth/strategies/bitly.rb +46 -0
- data/oa-oauth/lib/omniauth/strategies/dailymile.rb +64 -0
- data/oa-oauth/lib/omniauth/strategies/doit.rb +60 -0
- data/oa-oauth/lib/omniauth/strategies/dopplr.rb +53 -0
- data/oa-oauth/lib/omniauth/strategies/douban.rb +60 -0
- data/oa-oauth/lib/omniauth/strategies/evernote.rb +54 -0
- data/oa-oauth/lib/omniauth/strategies/facebook.rb +70 -0
- data/oa-oauth/lib/omniauth/strategies/foursquare.rb +62 -0
- data/oa-oauth/lib/omniauth/strategies/github.rb +50 -0
- data/oa-oauth/lib/omniauth/strategies/goodreads.rb +44 -0
- data/oa-oauth/lib/omniauth/strategies/google.rb +80 -0
- data/oa-oauth/lib/omniauth/strategies/gowalla.rb +64 -0
- data/oa-oauth/lib/omniauth/strategies/hyves.rb +67 -0
- data/oa-oauth/lib/omniauth/strategies/identica.rb +49 -0
- data/oa-oauth/lib/omniauth/strategies/instagram.rb +56 -0
- data/oa-oauth/lib/omniauth/strategies/instapaper.rb +40 -0
- data/oa-oauth/lib/omniauth/strategies/linked_in.rb +55 -0
- data/oa-oauth/lib/omniauth/strategies/meetup.rb +56 -0
- data/oa-oauth/lib/omniauth/strategies/miso.rb +41 -0
- data/oa-oauth/lib/omniauth/strategies/mixi.rb +59 -0
- data/oa-oauth/lib/omniauth/strategies/netflix.rb +65 -0
- data/oa-oauth/lib/omniauth/strategies/oauth.rb +85 -0
- data/oa-oauth/lib/omniauth/strategies/oauth2.rb +98 -0
- data/oa-oauth/lib/omniauth/strategies/qzone.rb +69 -0
- data/oa-oauth/lib/omniauth/strategies/rdio.rb +45 -0
- data/oa-oauth/lib/omniauth/strategies/renren.rb +87 -0
- data/oa-oauth/lib/omniauth/strategies/salesforce.rb +44 -0
- data/oa-oauth/lib/omniauth/strategies/smug_mug.rb +42 -0
- data/oa-oauth/lib/omniauth/strategies/sound_cloud.rb +46 -0
- data/oa-oauth/lib/omniauth/strategies/t163.rb +57 -0
- data/oa-oauth/lib/omniauth/strategies/teambox.rb +49 -0
- data/oa-oauth/lib/omniauth/strategies/thirty_seven_signals.rb +41 -0
- data/oa-oauth/lib/omniauth/strategies/tqq.rb +64 -0
- data/oa-oauth/lib/omniauth/strategies/trade_me.rb +45 -0
- data/oa-oauth/lib/omniauth/strategies/trip_it.rb +22 -0
- data/oa-oauth/lib/omniauth/strategies/tsina.rb +79 -0
- data/oa-oauth/lib/omniauth/strategies/tsohu.rb +57 -0
- data/oa-oauth/lib/omniauth/strategies/tumblr.rb +60 -0
- data/oa-oauth/lib/omniauth/strategies/twitter.rb +57 -0
- data/oa-oauth/lib/omniauth/strategies/type_pad.rb +76 -0
- data/oa-oauth/lib/omniauth/strategies/vimeo.rb +54 -0
- data/oa-oauth/lib/omniauth/strategies/vkontakte.rb +84 -0
- data/oa-oauth/lib/omniauth/strategies/xauth.rb +67 -0
- data/oa-oauth/lib/omniauth/strategies/yahoo.rb +55 -0
- data/oa-oauth/lib/omniauth/strategies/yammer.rb +43 -0
- data/oa-oauth/lib/omniauth/strategies/you_tube.rb +73 -0
- data/oa-oauth/lib/omniauth/version.rb +19 -0
- data/oa-oauth/oa-oauth.gemspec +33 -0
- data/oa-oauth/spec/fixtures/basecamp_200.xml +24 -0
- data/oa-oauth/spec/fixtures/campfire_200.json +10 -0
- data/oa-oauth/spec/omniauth/strategies/bitly_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/dailymile_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/doit_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/dopplr_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/douban_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/evernote_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/facebook_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/foursquare_spec.rb +18 -0
- data/oa-oauth/spec/omniauth/strategies/github_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/goodreads_spec.rb +6 -0
- data/oa-oauth/spec/omniauth/strategies/google_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/gowalla_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/hyves_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/identica_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/linked_in_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/meetup_spec.rb +14 -0
- data/oa-oauth/spec/omniauth/strategies/miso_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/netflix_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/oauth2_spec.rb +0 -0
- data/oa-oauth/spec/omniauth/strategies/oauth_spec.rb +77 -0
- data/oa-oauth/spec/omniauth/strategies/rdio_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/salesforce_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/smug_mug_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/sound_cloud_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/t163_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/teambox_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/thirty_seven_signals_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/trade_me_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/trip_it_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/tsina_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/tumblr_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/twitter_spec.rb +20 -0
- data/oa-oauth/spec/omniauth/strategies/type_pad_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/vimeo_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/vkontakte_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/yahoo_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/yammer_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/you_tube_spec.rb +5 -0
- data/oa-oauth/spec/spec_helper.rb +27 -0
- data/oa-oauth/spec/support/shared_examples.rb +29 -0
- data/oa-openid/.gemtest +0 -0
- data/oa-openid/.rspec +3 -0
- data/oa-openid/.yardopts +4 -0
- data/oa-openid/LICENSE +19 -0
- data/oa-openid/README.rdoc +51 -0
- data/oa-openid/Rakefile +6 -0
- data/oa-openid/lib/oa-openid.rb +1 -0
- data/oa-openid/lib/omniauth/openid.rb +59 -0
- data/oa-openid/lib/omniauth/openid/gapps.rb +32 -0
- data/oa-openid/lib/omniauth/strategies/google_apps.rb +23 -0
- data/oa-openid/lib/omniauth/strategies/open_id.rb +132 -0
- data/oa-openid/lib/omniauth/version.rb +19 -0
- data/oa-openid/oa-openid.gemspec +29 -0
- data/oa-openid/spec/omniauth/strategies/open_id_spec.rb +71 -0
- data/oa-openid/spec/spec_helper.rb +14 -0
- data/omniauth.gemspec +3 -3
- data/tasks/all.rb +134 -0
- metadata +199 -9
- data/README.rdoc +0 -17
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            require File.expand_path('../lib/omniauth/version', __FILE__)
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Gem::Specification.new do |gem|
         | 
| 5 | 
            +
              gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
         | 
| 6 | 
            +
              gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
         | 
| 7 | 
            +
              gem.add_runtime_dependency 'rest-client', '~> 1.6.0'
         | 
| 8 | 
            +
              gem.add_development_dependency 'maruku', '~> 0.6'
         | 
| 9 | 
            +
              gem.add_development_dependency 'simplecov', '~> 0.4'
         | 
| 10 | 
            +
              gem.add_development_dependency 'rack-test', '~> 0.5'
         | 
| 11 | 
            +
              gem.add_development_dependency 'rake', '~> 0.8'
         | 
| 12 | 
            +
              gem.add_development_dependency 'rspec', '~> 2.5'
         | 
| 13 | 
            +
              gem.add_development_dependency 'webmock', '~> 1.6'
         | 
| 14 | 
            +
              gem.add_development_dependency 'yard', '~> 0.6'
         | 
| 15 | 
            +
              gem.add_development_dependency 'ZenTest', '~> 4.5'
         | 
| 16 | 
            +
              gem.name = 'oa-basic'
         | 
| 17 | 
            +
              gem.version = OmniAuth::Version::STRING
         | 
| 18 | 
            +
              gem.description = %q{HTTP Basic strategies for OmniAuth.}
         | 
| 19 | 
            +
              gem.summary = gem.description
         | 
| 20 | 
            +
              gem.email = ['michael@intridea.com', 'sferik@gmail.com']
         | 
| 21 | 
            +
              gem.homepage = 'http://github.com/intridea/omniauth'
         | 
| 22 | 
            +
              gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
         | 
| 23 | 
            +
              gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
         | 
| 24 | 
            +
              gem.files = `git ls-files`.split("\n")
         | 
| 25 | 
            +
              gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 26 | 
            +
              gem.require_paths = ['lib']
         | 
| 27 | 
            +
              gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
         | 
| 28 | 
            +
            end
         | 
    
        data/oa-core/.gemtest
    ADDED
    
    | 
            File without changes
         | 
    
        data/oa-core/.rspec
    ADDED
    
    
    
        data/oa-core/.yardopts
    ADDED
    
    
    
        data/oa-core/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/oa-core/Rakefile
    ADDED
    
    
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            Autotest.add_discovery { "rspec2" }
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            require 'omniauth/core'
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'omniauth/core'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module OmniAuth
         | 
| 4 | 
            +
              class Builder < ::Rack::Builder
         | 
| 5 | 
            +
                def initialize(app, &block)
         | 
| 6 | 
            +
                  @app = app
         | 
| 7 | 
            +
                  super(&block)
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def on_failure(&block)
         | 
| 11 | 
            +
                  OmniAuth.config.on_failure = block
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def configure(&block)
         | 
| 15 | 
            +
                  OmniAuth.configure(&block)
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def provider(klass, *args, &block)
         | 
| 19 | 
            +
                  if klass.is_a?(Class)
         | 
| 20 | 
            +
                    middleware = klass
         | 
| 21 | 
            +
                  else
         | 
| 22 | 
            +
                    middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  use middleware, *args, &block
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                def call(env)
         | 
| 29 | 
            +
                  @ins << @app unless @ins.include?(@app)
         | 
| 30 | 
            +
                  to_app.call(env)
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,135 @@ | |
| 1 | 
            +
            require 'rack'
         | 
| 2 | 
            +
            require 'singleton'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies; end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              autoload :Builder,  'omniauth/builder'
         | 
| 8 | 
            +
              autoload :Strategy, 'omniauth/strategy'
         | 
| 9 | 
            +
              autoload :Test,     'omniauth/test'
         | 
| 10 | 
            +
              autoload :Form,     'omniauth/form'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def self.strategies
         | 
| 13 | 
            +
                @@strategies ||= []
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              class Configuration
         | 
| 17 | 
            +
                include Singleton
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                @@defaults = {
         | 
| 20 | 
            +
                  :path_prefix => '/auth',
         | 
| 21 | 
            +
                  :on_failure => Proc.new do |env|
         | 
| 22 | 
            +
                    message_key = env['omniauth.error.type']
         | 
| 23 | 
            +
                    new_path = "#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
         | 
| 24 | 
            +
                    [302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
         | 
| 25 | 
            +
                  end,
         | 
| 26 | 
            +
                  :form_css => Form::DEFAULT_CSS,
         | 
| 27 | 
            +
                  :test_mode => false,
         | 
| 28 | 
            +
                  :allowed_request_methods => [:get, :post],
         | 
| 29 | 
            +
                  :mock_auth => {
         | 
| 30 | 
            +
                    :default => {
         | 
| 31 | 
            +
                      'provider' => 'default',
         | 
| 32 | 
            +
                      'uid' => '1234',
         | 
| 33 | 
            +
                      'user_info' => {
         | 
| 34 | 
            +
                        'name' => 'Bob Example'
         | 
| 35 | 
            +
                      }
         | 
| 36 | 
            +
                    }
         | 
| 37 | 
            +
                  }
         | 
| 38 | 
            +
                }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def self.defaults
         | 
| 41 | 
            +
                  @@defaults
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                def initialize
         | 
| 45 | 
            +
                  @@defaults.each_pair{|k,v| self.send("#{k}=",v)}
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                def on_failure(&block)
         | 
| 49 | 
            +
                  if block_given?
         | 
| 50 | 
            +
                    @on_failure = block
         | 
| 51 | 
            +
                  else
         | 
| 52 | 
            +
                    @on_failure
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def add_mock(provider, mock={})
         | 
| 57 | 
            +
                  # Stringify keys recursively one level.
         | 
| 58 | 
            +
                  mock.stringify_keys!
         | 
| 59 | 
            +
                  mock.keys.each do|key|
         | 
| 60 | 
            +
                    if mock[key].is_a? Hash
         | 
| 61 | 
            +
                      mock[key].stringify_keys!
         | 
| 62 | 
            +
                    end
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  # Merge with the default mock and ensure provider is correct.
         | 
| 66 | 
            +
                  mock = self.mock_auth[:default].dup.merge(mock)
         | 
| 67 | 
            +
                  mock["provider"] = provider.to_s
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  # Add it to the mocks.
         | 
| 70 | 
            +
                  self.mock_auth[provider.to_sym] = mock
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                attr_writer :on_failure
         | 
| 74 | 
            +
                attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
              def self.config
         | 
| 78 | 
            +
                Configuration.instance
         | 
| 79 | 
            +
              end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
              def self.configure
         | 
| 82 | 
            +
                yield config
         | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
              def self.mock_auth_for(provider)
         | 
| 86 | 
            +
                config.mock_auth[provider.to_sym] || config.mock_auth[:default]
         | 
| 87 | 
            +
              end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
              module Utils
         | 
| 90 | 
            +
                CAMELIZE_SPECIAL = {
         | 
| 91 | 
            +
                  'oauth' => 'OAuth',
         | 
| 92 | 
            +
                  'oauth2' => 'OAuth2',
         | 
| 93 | 
            +
                  'openid' => 'OpenID',
         | 
| 94 | 
            +
                  'open_id' => 'OpenID',
         | 
| 95 | 
            +
                  'github' => 'GitHub',
         | 
| 96 | 
            +
                  'tripit' => 'TripIt',
         | 
| 97 | 
            +
                  'soundcloud' => 'SoundCloud',
         | 
| 98 | 
            +
                  'smugmug' => 'SmugMug',
         | 
| 99 | 
            +
                  'cas' => 'CAS',
         | 
| 100 | 
            +
                  'trademe' => 'TradeMe',
         | 
| 101 | 
            +
                  'ldap'  => 'LDAP'
         | 
| 102 | 
            +
                }
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                module_function
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                def form_css
         | 
| 107 | 
            +
                  "<style type='text/css'>#{OmniAuth.config.form_css}</style>"
         | 
| 108 | 
            +
                end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                def deep_merge(hash, other_hash)
         | 
| 111 | 
            +
                  target = hash.dup
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                  other_hash.keys.each do |key|
         | 
| 114 | 
            +
                    if other_hash[key].is_a? ::Hash and hash[key].is_a? ::Hash
         | 
| 115 | 
            +
                      target[key] = deep_merge(target[key],other_hash[key])
         | 
| 116 | 
            +
                      next
         | 
| 117 | 
            +
                    end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                    target[key] = other_hash[key]
         | 
| 120 | 
            +
                  end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                  target
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                def camelize(word, first_letter_in_uppercase = true)
         | 
| 126 | 
            +
                  return CAMELIZE_SPECIAL[word.to_s] if CAMELIZE_SPECIAL[word.to_s]
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                  if first_letter_in_uppercase
         | 
| 129 | 
            +
                    word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
         | 
| 130 | 
            +
                  else
         | 
| 131 | 
            +
                    word.first + camelize(word)[1..-1]
         | 
| 132 | 
            +
                  end
         | 
| 133 | 
            +
                end
         | 
| 134 | 
            +
              end
         | 
| 135 | 
            +
            end
         | 
| @@ -0,0 +1,184 @@ | |
| 1 | 
            +
            require 'omniauth/core'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module OmniAuth
         | 
| 4 | 
            +
              class Form
         | 
| 5 | 
            +
                DEFAULT_CSS = <<-CSS
         | 
| 6 | 
            +
                body {
         | 
| 7 | 
            +
                  background: #ccc;
         | 
| 8 | 
            +
                  font-family: "Lucida Grande", "Lucida Sans", Helvetica, Arial, sans-serif;
         | 
| 9 | 
            +
                }
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                h1 {
         | 
| 12 | 
            +
                  text-align: center;
         | 
| 13 | 
            +
                  margin: 30px auto 0px;
         | 
| 14 | 
            +
                  font-size: 18px;
         | 
| 15 | 
            +
                  padding: 10px 10px 15px;
         | 
| 16 | 
            +
                  background: #555;
         | 
| 17 | 
            +
                  color: white;
         | 
| 18 | 
            +
                  width: 320px;
         | 
| 19 | 
            +
                  border: 10px solid #444;
         | 
| 20 | 
            +
                  border-bottom: 0;
         | 
| 21 | 
            +
                  -moz-border-radius-topleft: 10px;
         | 
| 22 | 
            +
                  -moz-border-radius-topright: 10px;
         | 
| 23 | 
            +
                  -webkit-border-top-left-radius: 10px;
         | 
| 24 | 
            +
                  -webkit-border-top-right-radius: 10px;
         | 
| 25 | 
            +
                  border-top-left-radius: 10px;
         | 
| 26 | 
            +
                  border-top-right-radius: 10px;
         | 
| 27 | 
            +
                }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                h1, form {
         | 
| 30 | 
            +
                  -moz-box-shadow: 2px 2px 7px rgba(0,0,0,0.3);
         | 
| 31 | 
            +
                  -webkit-box-shadow: 2px 2px 7px rgba(0,0,0,0.3);
         | 
| 32 | 
            +
                }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                form {
         | 
| 35 | 
            +
                  background: white;
         | 
| 36 | 
            +
                  border: 10px solid #eee;
         | 
| 37 | 
            +
                  border-top: 0;
         | 
| 38 | 
            +
                  padding: 20px;
         | 
| 39 | 
            +
                  margin: 0px auto 40px;
         | 
| 40 | 
            +
                  width: 300px;
         | 
| 41 | 
            +
                  -moz-border-radius-bottomleft: 10px;
         | 
| 42 | 
            +
                  -moz-border-radius-bottomright: 10px;
         | 
| 43 | 
            +
                  -webkit-border-bottom-left-radius: 10px;
         | 
| 44 | 
            +
                  -webkit-border-bottom-right-radius: 10px;
         | 
| 45 | 
            +
                  border-bottom-left-radius: 10px;
         | 
| 46 | 
            +
                  border-bottom-right-radius: 10px;
         | 
| 47 | 
            +
                }
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                label {
         | 
| 50 | 
            +
                  display: block;
         | 
| 51 | 
            +
                  font-weight: bold;
         | 
| 52 | 
            +
                  margin-bottom: 5px;
         | 
| 53 | 
            +
                }
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                input {
         | 
| 56 | 
            +
                  font-size: 18px;
         | 
| 57 | 
            +
                  padding: 4px 8px;
         | 
| 58 | 
            +
                  display: block;
         | 
| 59 | 
            +
                  margin-bottom: 10px;
         | 
| 60 | 
            +
                  width: 280px;
         | 
| 61 | 
            +
                }
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                input#identifier, input#openid_url {
         | 
| 64 | 
            +
                  background: url(http://openid.net/login-bg.gif) no-repeat;
         | 
| 65 | 
            +
                  background-position: 0 50%;
         | 
| 66 | 
            +
                  padding-left: 18px;
         | 
| 67 | 
            +
                }
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                button {
         | 
| 70 | 
            +
                  font-size: 22px;
         | 
| 71 | 
            +
                  padding: 4px 8px;
         | 
| 72 | 
            +
                  display: block;
         | 
| 73 | 
            +
                  margin: 20px auto 0;
         | 
| 74 | 
            +
                }
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                fieldset {
         | 
| 77 | 
            +
                  border: 1px solid #ccc;
         | 
| 78 | 
            +
                  border-left: 0;
         | 
| 79 | 
            +
                  border-right: 0;
         | 
| 80 | 
            +
                  padding: 10px 0;
         | 
| 81 | 
            +
                }
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                fieldset input {
         | 
| 84 | 
            +
                  width: 260px;
         | 
| 85 | 
            +
                  font-size: 16px;
         | 
| 86 | 
            +
                }
         | 
| 87 | 
            +
                CSS
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                attr_accessor :options
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                def initialize(options = {})
         | 
| 92 | 
            +
                  options[:title] ||= "Authentication Info Required"
         | 
| 93 | 
            +
                  self.options = options
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  @html = ""
         | 
| 96 | 
            +
                  header(options[:title])
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                def self.build(title=nil, &block)
         | 
| 100 | 
            +
                  form = OmniAuth::Form.new(title)
         | 
| 101 | 
            +
                  form.instance_eval(&block)
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                def label_field(text, target)
         | 
| 105 | 
            +
                  @html << "\n<label for='#{target}'>#{text}:</label>"
         | 
| 106 | 
            +
                  self
         | 
| 107 | 
            +
                end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                def input_field(type, name)
         | 
| 110 | 
            +
                  @html << "\n<input type='#{type}' id='#{name}' name='#{name}'/>"
         | 
| 111 | 
            +
                  self
         | 
| 112 | 
            +
                end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                def text_field(label, name)
         | 
| 115 | 
            +
                  label_field(label, name)
         | 
| 116 | 
            +
                  input_field('text', name)
         | 
| 117 | 
            +
                  self
         | 
| 118 | 
            +
                end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                def password_field(label, name)
         | 
| 121 | 
            +
                  label_field(label, name)
         | 
| 122 | 
            +
                  input_field('password', name)
         | 
| 123 | 
            +
                  self
         | 
| 124 | 
            +
                end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                def button(text)
         | 
| 127 | 
            +
                  @html << "\n<button type='submit'>#{text}</button>"
         | 
| 128 | 
            +
                end
         | 
| 129 | 
            +
             | 
| 130 | 
            +
                def html(html)
         | 
| 131 | 
            +
                  @html << html
         | 
| 132 | 
            +
                end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                def fieldset(legend, options = {}, &block)
         | 
| 135 | 
            +
                  @html << "\n<fieldset#{" style='#{options[:style]}'" if options[:style]}#{" id='#{options[:id]}'" if options[:id]}>\n  <legend>#{legend}</legend>\n"
         | 
| 136 | 
            +
                  self.instance_eval &block
         | 
| 137 | 
            +
                  @html << "\n</fieldset>"
         | 
| 138 | 
            +
                  self
         | 
| 139 | 
            +
                end
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                def header(title)
         | 
| 142 | 
            +
                  @html << <<-HTML
         | 
| 143 | 
            +
                  <!DOCTYPE html>
         | 
| 144 | 
            +
                  <html>
         | 
| 145 | 
            +
                  <head>
         | 
| 146 | 
            +
                    <title>#{title}</title>
         | 
| 147 | 
            +
                    #{css}
         | 
| 148 | 
            +
                  </head>
         | 
| 149 | 
            +
                  <body>
         | 
| 150 | 
            +
                  <h1>#{title}</h1>
         | 
| 151 | 
            +
                  <form method='post' #{"action='#{options[:url]}' " if options[:url]}noValidate='noValidate'>
         | 
| 152 | 
            +
                  HTML
         | 
| 153 | 
            +
                  self
         | 
| 154 | 
            +
                end
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                def footer
         | 
| 157 | 
            +
                  return self if @footer
         | 
| 158 | 
            +
                  @html << <<-HTML
         | 
| 159 | 
            +
                  <button type='submit'>Connect</button>
         | 
| 160 | 
            +
                  </form>
         | 
| 161 | 
            +
                  </body>
         | 
| 162 | 
            +
                  </html>
         | 
| 163 | 
            +
                  HTML
         | 
| 164 | 
            +
                  @footer = true
         | 
| 165 | 
            +
                  self
         | 
| 166 | 
            +
                end
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                def to_html
         | 
| 169 | 
            +
                  footer
         | 
| 170 | 
            +
                  @html
         | 
| 171 | 
            +
                end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                def to_response
         | 
| 174 | 
            +
                  footer
         | 
| 175 | 
            +
                  Rack::Response.new(@html).finish
         | 
| 176 | 
            +
                end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                protected
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                def css
         | 
| 181 | 
            +
                  "\n<style type='text/css'>#{OmniAuth.config.form_css}</style>"
         | 
| 182 | 
            +
                end
         | 
| 183 | 
            +
              end
         | 
| 184 | 
            +
            end
         |