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,44 @@ | |
| 1 | 
            +
            require 'omniauth/strategies/oauth2'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module OmniAuth
         | 
| 4 | 
            +
              module Strategies
         | 
| 5 | 
            +
                class Salesforce < OmniAuth::Strategies::OAuth2
         | 
| 6 | 
            +
                  def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
         | 
| 7 | 
            +
                    client_options = {
         | 
| 8 | 
            +
                      :site => 'https://login.salesforce.com',
         | 
| 9 | 
            +
                      :authorize_path => '/services/oauth2/authorize',
         | 
| 10 | 
            +
                      :access_token_path => '/services/oauth2/token'
         | 
| 11 | 
            +
                    }
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                    options.merge!(:response_type => 'code', :grant_type => 'authorization_code')
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    super(app, :salesforce, consumer_key, consumer_secret, client_options, options, &block)
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def auth_hash
         | 
| 19 | 
            +
                    data = user_data
         | 
| 20 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 21 | 
            +
                      'uid' => @access_token['id'],
         | 
| 22 | 
            +
                      'credentials' => {
         | 
| 23 | 
            +
                        'instance_url' => @access_token['instance_url']
         | 
| 24 | 
            +
                       },
         | 
| 25 | 
            +
                      'extra' => {'user_hash' => data},
         | 
| 26 | 
            +
                      'user_info' => {
         | 
| 27 | 
            +
                        'email' => data['email'],
         | 
| 28 | 
            +
                        'name' => data['display_name']
         | 
| 29 | 
            +
                      }
         | 
| 30 | 
            +
                    })
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  def user_data
         | 
| 34 | 
            +
                    @data ||= MultiJson.decode(@access_token.get(@access_token['id']))
         | 
| 35 | 
            +
                  rescue ::OAuth2::HTTPError => e
         | 
| 36 | 
            +
                    if e.response.status == 302
         | 
| 37 | 
            +
                      @data ||= MultiJson.decode(@access_token.get(e.response.headers['location']))
         | 
| 38 | 
            +
                    else
         | 
| 39 | 
            +
                      raise e
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # Authenticate to SmugMug via OAuth and retrieve basic user information.
         | 
| 8 | 
            +
                # Usage:
         | 
| 9 | 
            +
                #    use OmniAuth::Strategies::SmugMug, 'consumerkey', 'consumersecret'
         | 
| 10 | 
            +
                #
         | 
| 11 | 
            +
                class SmugMug < OmniAuth::Strategies::OAuth
         | 
| 12 | 
            +
                  def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
         | 
| 13 | 
            +
                    super(app, :smugmug, consumer_key, consumer_secret,
         | 
| 14 | 
            +
                            {:site               => 'http://api.smugmug.com',
         | 
| 15 | 
            +
                            :request_token_path => "/services/oauth/getRequestToken.mg",
         | 
| 16 | 
            +
                            :access_token_path  => "/services/oauth/getAccessToken.mg",
         | 
| 17 | 
            +
                            :authorize_path     => "/services/oauth/authorize.mg"}, options, &block)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def auth_hash
         | 
| 21 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 22 | 
            +
                      'uid' => user_hash['id'],
         | 
| 23 | 
            +
                      'user_info' => user_info,
         | 
| 24 | 
            +
                      'extra' => { 'user_hash' => user_hash }
         | 
| 25 | 
            +
                    })
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  # user info according to schema
         | 
| 29 | 
            +
                  def user_info
         | 
| 30 | 
            +
                    {
         | 
| 31 | 
            +
                      'nickname' => user_hash['NickName'],
         | 
| 32 | 
            +
                      'name' => user_hash['NickName']
         | 
| 33 | 
            +
                    }
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  # info as supplied by SmugMug
         | 
| 37 | 
            +
                  def user_hash
         | 
| 38 | 
            +
                    @user_hash ||= MultiJson.decode(@access_token.get('/services/api/json/1.2.2/?method=smugmug.auth.checkAccessToken').body)['Auth']['User']
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # Authenticate to SoundCloud via OAuth and retrieve basic
         | 
| 8 | 
            +
                # user information.
         | 
| 9 | 
            +
                #
         | 
| 10 | 
            +
                # Usage:
         | 
| 11 | 
            +
                #
         | 
| 12 | 
            +
                #    use OmniAuth::Strategies::SoundCloud, 'consumerkey', 'consumersecret'
         | 
| 13 | 
            +
                #
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                class SoundCloud < OmniAuth::Strategies::OAuth
         | 
| 16 | 
            +
                  def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
         | 
| 17 | 
            +
                    super(app, :soundcloud, consumer_key, consumer_secret, {:site => 'https://api.soundcloud.com'}, options)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def auth_hash
         | 
| 21 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 22 | 
            +
                      'uid' => user_hash['id'],
         | 
| 23 | 
            +
                      'user_info' => user_info,
         | 
| 24 | 
            +
                      'extra' => {'user_hash' => user_hash}
         | 
| 25 | 
            +
                    })
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def user_info
         | 
| 29 | 
            +
                    user_hash = self.user_hash
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    {
         | 
| 32 | 
            +
                      'name' => user_hash['full_name'],
         | 
| 33 | 
            +
                      'nickname' => user_hash['username'],
         | 
| 34 | 
            +
                      'location' => user_hash['city'],
         | 
| 35 | 
            +
                      'description' => user_hash['description'],
         | 
| 36 | 
            +
                      'image' => user_hash['avatar_url'],
         | 
| 37 | 
            +
                      'urls' => {'Website' => user_hash['website']}
         | 
| 38 | 
            +
                    }
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  def user_hash
         | 
| 42 | 
            +
                    @user_hash ||= MultiJson.decode(@access_token.get('/me.json').body)
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
| @@ -0,0 +1,57 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # Authenticate to T163 via OAuth and retrieve basic
         | 
| 8 | 
            +
                # user information.
         | 
| 9 | 
            +
                #
         | 
| 10 | 
            +
                # Usage:
         | 
| 11 | 
            +
                #
         | 
| 12 | 
            +
                #    use OmniAuth::Strategies::T163, 'APIKey', 'APIKeySecret'
         | 
| 13 | 
            +
                #
         | 
| 14 | 
            +
                class T163 < OmniAuth::Strategies::OAuth
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
         | 
| 17 | 
            +
                    @api_key = consumer_key
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    client_options = {
         | 
| 20 | 
            +
                      :site               => 'http://api.t.163.com',
         | 
| 21 | 
            +
                      :request_token_path => '/oauth/request_token',
         | 
| 22 | 
            +
                      :access_token_path  => '/oauth/access_token',
         | 
| 23 | 
            +
                      :authorize_path     => '/oauth/authenticate',
         | 
| 24 | 
            +
                      :realm              => 'OmniAuth'
         | 
| 25 | 
            +
                    }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    super(app, :t163, consumer_key, consumer_secret, client_options, options, &block)
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def auth_hash
         | 
| 31 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 32 | 
            +
                      'uid' => user_hash['screen_name'],
         | 
| 33 | 
            +
                      'user_info' => user_info,
         | 
| 34 | 
            +
                      'extra' => {'user_hash' => user_hash}
         | 
| 35 | 
            +
                    })
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  def user_info
         | 
| 39 | 
            +
                    user_hash = self.user_hash
         | 
| 40 | 
            +
                    {
         | 
| 41 | 
            +
                      'username' => user_hash['name'],
         | 
| 42 | 
            +
                      'name' => user_hash['realName'],
         | 
| 43 | 
            +
                      'location' => user_hash['location'],
         | 
| 44 | 
            +
                      'image' => user_hash['profile_image_url'],
         | 
| 45 | 
            +
                      'description' => user_hash['description'],
         | 
| 46 | 
            +
                      'urls' => {
         | 
| 47 | 
            +
                        'T163' => 'http://t.163.com'
         | 
| 48 | 
            +
                      }
         | 
| 49 | 
            +
                    }
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  def user_hash
         | 
| 53 | 
            +
                    @user_hash ||= MultiJson.decode(@access_token.get("http://api.t.163.com/account/verify_credentials.json").body)
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
            end
         | 
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies
         | 
| 6 | 
            +
                class Teambox < OAuth2
         | 
| 7 | 
            +
                  def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
         | 
| 8 | 
            +
                    client_options = {
         | 
| 9 | 
            +
                      :site => "https://teambox.com/",
         | 
| 10 | 
            +
                      :authorize_path => "/oauth/authorize",
         | 
| 11 | 
            +
                      :access_token_path => "/oauth/token"
         | 
| 12 | 
            +
                    }
         | 
| 13 | 
            +
                    super(app, :teambox, client_id, client_secret, client_options, options, &block)
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
                  def request_phase
         | 
| 16 | 
            +
                    options[:scope] ||= "offline_access"
         | 
| 17 | 
            +
                    options[:response_type] ||= 'code'
         | 
| 18 | 
            +
                    super
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def callback_phase
         | 
| 22 | 
            +
                    options[:grant_type] ||= 'authorization_code'
         | 
| 23 | 
            +
                    super
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  def user_data
         | 
| 27 | 
            +
                    @data ||= MultiJson.decode(@access_token.get("/api/1/account"))
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def user_info
         | 
| 31 | 
            +
                    {
         | 
| 32 | 
            +
                      'nickname' => user_data['username'],
         | 
| 33 | 
            +
                      'name' => user_data['first_name'],
         | 
| 34 | 
            +
                      'image' => user_data['avatar_url'],
         | 
| 35 | 
            +
                      'urls' => {}
         | 
| 36 | 
            +
                    }
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  def auth_hash
         | 
| 40 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 41 | 
            +
                      'uid' => user_data['id'],
         | 
| 42 | 
            +
                      'user_info' => user_info,
         | 
| 43 | 
            +
                      'extra' => {'user_hash' => user_data}
         | 
| 44 | 
            +
                    })
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
            end
         | 
| 49 | 
            +
             | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies
         | 
| 6 | 
            +
                class ThirtySevenSignals < OAuth2
         | 
| 7 | 
            +
                  def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
         | 
| 8 | 
            +
                    client_options = {
         | 
| 9 | 
            +
                      :site => 'https://launchpad.37signals.com/',
         | 
| 10 | 
            +
                      :authorize_path => '/authorization/new',
         | 
| 11 | 
            +
                      :access_token_path => '/authorization/token'
         | 
| 12 | 
            +
                    }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    super(app, :thirty_seven_signals, client_id, client_secret, client_options, options, &block)
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def user_data
         | 
| 18 | 
            +
                    @data ||= MultiJson.decode(@access_token.get('/authorization.json'))
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def user_info
         | 
| 22 | 
            +
                    {
         | 
| 23 | 
            +
                      'email' => user_data['identity']['email_address'],
         | 
| 24 | 
            +
                      'first_name' => user_data['identity']['first_name'],
         | 
| 25 | 
            +
                      'last_name' => user_data['identity']['last_name'],
         | 
| 26 | 
            +
                      'name' => [user_data['identity']['first_name'], user_data['identity']['last_name']].join(' ').strip
         | 
| 27 | 
            +
                    }
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def auth_hash
         | 
| 31 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 32 | 
            +
                      'uid' => user_data['identity']['id'],
         | 
| 33 | 
            +
                      'user_info' => user_info,
         | 
| 34 | 
            +
                      'extra' => {
         | 
| 35 | 
            +
                        'accounts' => user_data['accounts']
         | 
| 36 | 
            +
                      }
         | 
| 37 | 
            +
                    })
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
| @@ -0,0 +1,64 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # Authenticate to Tqq via OAuth and retrieve basic
         | 
| 8 | 
            +
                # user information.
         | 
| 9 | 
            +
                #
         | 
| 10 | 
            +
                # Usage:
         | 
| 11 | 
            +
                #
         | 
| 12 | 
            +
                #    use OmniAuth::Strategies::Tqq, 'APIKey', 'APIKeySecret'
         | 
| 13 | 
            +
                #
         | 
| 14 | 
            +
                class Tqq < OmniAuth::Strategies::OAuth
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
         | 
| 17 | 
            +
                    @api_key = consumer_key
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    client_options = {
         | 
| 20 | 
            +
                      :site               => 'https://open.t.qq.com',
         | 
| 21 | 
            +
                      :request_token_path => '/cgi-bin/request_token',
         | 
| 22 | 
            +
                      :access_token_path  => '/cgi-bin/access_token',
         | 
| 23 | 
            +
                      :authorize_path     => '/cgi-bin/authorize',
         | 
| 24 | 
            +
                      :realm              => 'OmniAuth',
         | 
| 25 | 
            +
                      :scheme             => :query_string,
         | 
| 26 | 
            +
                      :nonce              => nonce,
         | 
| 27 | 
            +
                      :http_method        => :get,
         | 
| 28 | 
            +
                    }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                    super(app, :tqq, consumer_key, consumer_secret, client_options, options, &block)
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  def nonce
         | 
| 34 | 
            +
                    Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\W/, '')[0, 32]
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  def auth_hash
         | 
| 38 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 39 | 
            +
                      'uid' => user_hash["data"]['uid'],
         | 
| 40 | 
            +
                      'user_info' => user_info,
         | 
| 41 | 
            +
                      'extra' => {'user_hash' => user_hash}
         | 
| 42 | 
            +
                    })
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  def user_info
         | 
| 46 | 
            +
                    user_hash = self.user_hash
         | 
| 47 | 
            +
                    {
         | 
| 48 | 
            +
                      'username' => user_hash["data"]['name'],
         | 
| 49 | 
            +
                      'name' => user_hash["data"]['nick'],
         | 
| 50 | 
            +
                      'location' => user_hash["data"]['location'],
         | 
| 51 | 
            +
                      'image' => user_hash["data"]['head'],
         | 
| 52 | 
            +
                      'description' => user_hash['description'],
         | 
| 53 | 
            +
                      'urls' => {
         | 
| 54 | 
            +
                        'Tqq' => 't.qq.com'
         | 
| 55 | 
            +
                      }
         | 
| 56 | 
            +
                    }
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  def user_hash
         | 
| 60 | 
            +
                    @user_hash ||= MultiJson.decode(@access_token.get("http://open.t.qq.com/api/user/info?format=json").body)
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
            end
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # Authenticate to TradeMe via OAuth and retrieve basic user information.
         | 
| 8 | 
            +
                # Usage:
         | 
| 9 | 
            +
                #    use OmniAuth::Strategies::TradeMe, 'consumerkey', 'consumersecret'
         | 
| 10 | 
            +
                #
         | 
| 11 | 
            +
                class TradeMe < OmniAuth::Strategies::OAuth
         | 
| 12 | 
            +
                  def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
         | 
| 13 | 
            +
                    super(app, :trademe, consumer_key, consumer_secret,
         | 
| 14 | 
            +
                            {:site               => 'https://secure.trademe.co.nz',
         | 
| 15 | 
            +
                            :request_token_path  => "/Oauth/RequestToken",
         | 
| 16 | 
            +
                            :access_token_path   => "/Oauth/AccessToken",
         | 
| 17 | 
            +
                            :authorize_path      => "/Oauth/Authorize",
         | 
| 18 | 
            +
                            }, options, &block)
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def auth_hash
         | 
| 22 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 23 | 
            +
                      'uid'       => user_hash['MemberId'],
         | 
| 24 | 
            +
                      'user_info' => user_info,
         | 
| 25 | 
            +
                      'extra'     => { 'user_hash' => user_hash },
         | 
| 26 | 
            +
                    })
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  # user info according to schema
         | 
| 30 | 
            +
                  def user_info
         | 
| 31 | 
            +
                    {
         | 
| 32 | 
            +
                      'nickname'   => user_hash['Nickname'],
         | 
| 33 | 
            +
                      'first_name' => user_hash['FirstName'],
         | 
| 34 | 
            +
                      'last_name'  => user_hash['LastName'],
         | 
| 35 | 
            +
                      'name'       => [user_hash['FirstName'],user_hash['LastName']].reject{ |n| n.nil? || n.empty? }.join(' '),
         | 
| 36 | 
            +
                    }
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  # info as supplied by TradeMe user summary
         | 
| 40 | 
            +
                  def user_hash
         | 
| 41 | 
            +
                    @user_hash ||= MultiJson.decode(@access_token.get('https://api.trademe.co.nz/v1/MyTradeMe/Summary.json').body)
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module OmniAuth
         | 
| 4 | 
            +
              module Strategies
         | 
| 5 | 
            +
                #
         | 
| 6 | 
            +
                # Authenticate to TripIt via OAuth and retrieve an access token for API usage
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                # Usage:
         | 
| 9 | 
            +
                #
         | 
| 10 | 
            +
                #    use OmniAuth::Strategies::TripIt, 'consumerkey', 'consumersecret'
         | 
| 11 | 
            +
                #
         | 
| 12 | 
            +
                class TripIt < OmniAuth::Strategies::OAuth
         | 
| 13 | 
            +
                  def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
         | 
| 14 | 
            +
                    super(app, :tripit, consumer_key, consumer_secret,
         | 
| 15 | 
            +
                            {:site => 'https://api.tripit.com',
         | 
| 16 | 
            +
                            :request_token_path => "/oauth/request_token",
         | 
| 17 | 
            +
                            :access_token_path  => "/oauth/access_token",
         | 
| 18 | 
            +
                            :authorize_url     => "https://www.tripit.com/oauth/authorize"}, options, &block)
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,79 @@ | |
| 1 | 
            +
            require 'omniauth/oauth'
         | 
| 2 | 
            +
            require 'multi_json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module OmniAuth
         | 
| 5 | 
            +
              module Strategies
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # Authenticate to TSina via OAuth and retrieve basic
         | 
| 8 | 
            +
                # user information.
         | 
| 9 | 
            +
                #
         | 
| 10 | 
            +
                # Usage:
         | 
| 11 | 
            +
                #
         | 
| 12 | 
            +
                #    use OmniAuth::Strategies::TSina, 'APIKey', 'APIKeySecret'
         | 
| 13 | 
            +
                #
         | 
| 14 | 
            +
                class Tsina < OmniAuth::Strategies::OAuth
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
         | 
| 17 | 
            +
                    @api_key = consumer_key
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    client_options = {
         | 
| 20 | 
            +
                      :site               => 'http://api.t.sina.com.cn',
         | 
| 21 | 
            +
                      :request_token_path => '/oauth/request_token',
         | 
| 22 | 
            +
                      :access_token_path  => '/oauth/access_token',
         | 
| 23 | 
            +
                      :authorize_path     => '/oauth/authorize',
         | 
| 24 | 
            +
                      :realm              => 'OmniAuth'
         | 
| 25 | 
            +
                    }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    super(app, :tsina, consumer_key, consumer_secret, client_options, options, &block)
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def auth_hash
         | 
| 31 | 
            +
                    OmniAuth::Utils.deep_merge(super, {
         | 
| 32 | 
            +
                      'uid' => @access_token.params[:user_id],
         | 
| 33 | 
            +
                      'user_info' => user_info,
         | 
| 34 | 
            +
                      'extra' => {'user_hash' => user_hash}
         | 
| 35 | 
            +
                    })
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  def user_info
         | 
| 39 | 
            +
                    user_hash = self.user_hash
         | 
| 40 | 
            +
                    {
         | 
| 41 | 
            +
                      'username' => user_hash['screen_name'],
         | 
| 42 | 
            +
                      'name' => user_hash['name'],
         | 
| 43 | 
            +
                      'location' => user_hash['location'],
         | 
| 44 | 
            +
                      'image' => user_hash['profile_image_url'],
         | 
| 45 | 
            +
                      'description' => user_hash['description'],
         | 
| 46 | 
            +
                      'urls' => {
         | 
| 47 | 
            +
                        'Tsina' => user_hash['url']
         | 
| 48 | 
            +
                      }
         | 
| 49 | 
            +
                    }
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  # MonkeyPatch session['oauth']['tsina']['callback_confirmed'] to true
         | 
| 53 | 
            +
                  def request_phase
         | 
| 54 | 
            +
                    request_token = consumer.get_request_token(:oauth_callback => callback_url)
         | 
| 55 | 
            +
                    session['oauth'] ||= {}
         | 
| 56 | 
            +
                    session['oauth'][name.to_s] = {'callback_confirmed' => true, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
         | 
| 57 | 
            +
                    r = Rack::Response.new
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    if request_token.callback_confirmed?
         | 
| 60 | 
            +
                      r.redirect(request_token.authorize_url)
         | 
| 61 | 
            +
                    else
         | 
| 62 | 
            +
                      r.redirect(request_token.authorize_url(:oauth_callback => callback_url))
         | 
| 63 | 
            +
                    end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    r.finish
         | 
| 66 | 
            +
                  rescue ::Timeout::Error => e
         | 
| 67 | 
            +
                    fail!(:timeout, e)
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  def user_hash
         | 
| 71 | 
            +
                    # http://api.t.sina.com.cn/users/show/:id.json?source=appkey
         | 
| 72 | 
            +
                    # @access_token.params[:user_id] is the UID
         | 
| 73 | 
            +
                    # @api_key is the appkey
         | 
| 74 | 
            +
                    uid = @access_token.params[:user_id]
         | 
| 75 | 
            +
                    @user_hash ||= MultiJson.decode(@access_token.get("http://api.t.sina.com.cn/users/show/#{uid}.json?source=#{@api_key}").body)
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
            end
         |