devise_strategy_google_apps_open_social 1.0.0
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.
- checksums.yaml +15 -0
- data/.gitignore +20 -0
- data/.rspec +4 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +4 -0
- data/devise_strategy_google_apps_open_social.gemspec +30 -0
- data/lib/devise/strategies/google_apps_certificate.rb +11 -0
- data/lib/devise/strategies/google_apps_open_social.rb +40 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/strategy_spec.rb +211 -0
- metadata +184 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            !binary "U0hBMQ==":
         | 
| 3 | 
            +
              metadata.gz: !binary |-
         | 
| 4 | 
            +
                YTRkZDBiZjdmYzY5MTBiZTNkOGI4ODIzMzMzOWVlMmI1YzhlYmUzMg==
         | 
| 5 | 
            +
              data.tar.gz: !binary |-
         | 
| 6 | 
            +
                NzMzMTYyZjRkMzRmMjEwYWUwNzcwZDk4YzY1OTU0MDBjZmRiM2JiMQ==
         | 
| 7 | 
            +
            !binary "U0hBNTEy":
         | 
| 8 | 
            +
              metadata.gz: !binary |-
         | 
| 9 | 
            +
                ZDgwOGEwYmM2MTFjYTc2NDNkYzg4MWVkNTUyMzAyZGY3ZjY0MDc4M2M4NDM2
         | 
| 10 | 
            +
                MWVlNzJkMTVkOGM4NDMyZGJmYTkzYTNjZDY0NjcxNmI0M2NkOTMxODI5MDRi
         | 
| 11 | 
            +
                ZDhhNmEzNmZjMTlmZTE5MDBkNTk3MTAxNjBmYzAyODlmZGZiODU=
         | 
| 12 | 
            +
              data.tar.gz: !binary |-
         | 
| 13 | 
            +
                MDE5ZTNiYTdmNGUxMjNhZTMxNDgzYTBkNjQzN2MzODYyNmRmN2QxODdiNjU1
         | 
| 14 | 
            +
                Yzk3OTI0NGQ2ZmEyZDk4ODU4YTY1ZDA4MDljNmJkOWMyMGU5NTM4NDUwNzk2
         | 
| 15 | 
            +
                NjFjZDQ5ZGI4NTZkMzNkOTBhNTY1N2UxNTdjYjZlNWRlNWRmYjU=
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2013 Yesware
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            Google Apps OpenSocial Strategy
         | 
| 2 | 
            +
            ======
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Build Status: [](https://travis-ci.org/yesware/devise_strategy_google_apps_open_social)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Adds support to devise for authenticating an OpenSocial signed request.
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            Usage
         | 
| 9 | 
            +
            -----
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            In your devise initializer add:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ```ruby
         | 
| 14 | 
            +
            require 'devise/strategies/google_apps_open_social'
         | 
| 15 | 
            +
            config.warden do |manager|
         | 
| 16 | 
            +
            	manager.default_strategies(scope: :user).unshift :google_apps_open_social
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
            ```
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            Contributing
         | 
| 21 | 
            +
            ------------
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            1. Fork it
         | 
| 24 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 25 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 26 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 27 | 
            +
            5. Create new Pull Request
         | 
    
        data/Rakefile
    ADDED
    
    
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |spec|
         | 
| 6 | 
            +
              spec.name          = "devise_strategy_google_apps_open_social"
         | 
| 7 | 
            +
              spec.version       = '1.0.0'
         | 
| 8 | 
            +
              spec.author       = ["Yesware, Inc"]
         | 
| 9 | 
            +
              spec.email         = ["engineering@yesware.com'"]
         | 
| 10 | 
            +
              spec.description   = %q{Adds support to devise for authenticating an OpenSocial signed request.}
         | 
| 11 | 
            +
              spec.summary       = %q{Adds support to devise for authenticating an OpenSocial signed request.}
         | 
| 12 | 
            +
              spec.homepage      = ""
         | 
| 13 | 
            +
              spec.license       = "MIT"
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              spec.files         = `git ls-files`.split($/)
         | 
| 16 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 17 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 18 | 
            +
              spec.require_paths = ["lib"]
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              spec.add_dependency "oauth"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              spec.add_development_dependency "rake"
         | 
| 23 | 
            +
              spec.add_development_dependency "rspec"
         | 
| 24 | 
            +
              spec.add_development_dependency "devise"
         | 
| 25 | 
            +
              spec.add_development_dependency "warden"
         | 
| 26 | 
            +
              spec.add_development_dependency "rails"
         | 
| 27 | 
            +
              spec.add_development_dependency "timecop"
         | 
| 28 | 
            +
              spec.add_development_dependency "active_hash"
         | 
| 29 | 
            +
              spec.add_development_dependency "simplecov", ">= 0.7"
         | 
| 30 | 
            +
            end
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            module Devise
         | 
| 2 | 
            +
              module Strategies
         | 
| 3 | 
            +
                module GoogleAppsCertificate
         | 
| 4 | 
            +
                  # Google publishes their OpenID public key, we can use this
         | 
| 5 | 
            +
                  # to verify requests originating from a contextual gadget.
         | 
| 6 | 
            +
                  CONSUMER_KEY = 'www.google.com'
         | 
| 7 | 
            +
                  CONSUMER_SECRET = "-----BEGIN CERTIFICATE-----\nMIIDBDCCAm2gAwIBAgIJAK8dGINfkSTHMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV\nBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzETMBEG\nA1UEChMKR29vZ2xlIEluYzEXMBUGA1UEAxMOd3d3Lmdvb2dsZS5jb20wHhcNMDgx\nMDA4MDEwODMyWhcNMDkxMDA4MDEwODMyWjBgMQswCQYDVQQGEwJVUzELMAkGA1UE\nCBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxEzARBgNVBAoTCkdvb2dsZSBJ\nbmMxFzAVBgNVBAMTDnd3dy5nb29nbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GN\nADCBiQKBgQDQUV7ukIfIixbokHONGMW9+ed0E9X4m99I8upPQp3iAtqIvWs7XCbA\nbGqzQH1qX9Y00hrQ5RRQj8OI3tRiQs/KfzGWOdvLpIk5oXpdT58tg4FlYh5fbhIo\nVoVn4GvtSjKmJFsoM8NRtEJHL1aWd++dXzkQjEsNcBXwQvfDb0YnbQIDAQABo4HF\nMIHCMB0GA1UdDgQWBBSm/h1pNY91bNfW08ac9riYzs3cxzCBkgYDVR0jBIGKMIGH\ngBSm/h1pNY91bNfW08ac9riYzs3cx6FkpGIwYDELMAkGA1UEBhMCVVMxCzAJBgNV\nBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUg\nSW5jMRcwFQYDVQQDEw53d3cuZ29vZ2xlLmNvbYIJAK8dGINfkSTHMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAYpHTr3vQNsHHHUm4MkYcDB20a5KvcFoX\ngCcYtmdyd8rh/FKeZm2me7eQCXgBfJqQ4dvVLJ4LgIQiU3R5ZDe0WbW7rJ3M9ADQ\nFyQoRJP8OIMYW3BoMi0Z4E730KSLRh6kfLq4rK6vw7lkH9oynaHHWZSJLDAp17cP\nj+6znWkN9/g=\n-----END CERTIFICATE-----" 
         | 
| 8 | 
            +
                  CERTIFICATE_NAME = 'pub.1210278512.2713152949996518384.cer'
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            require "warden"
         | 
| 2 | 
            +
            require "devise"
         | 
| 3 | 
            +
            require "devise/strategies/google_apps_certificate"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Devise
         | 
| 6 | 
            +
              module Strategies
         | 
| 7 | 
            +
                class GoogleAppsOpenSocial < Devise::Strategies::Authenticatable
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  include GoogleAppsCertificate
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def valid?
         | 
| 12 | 
            +
                    params[:xoauth_public_key] == CERTIFICATE_NAME
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def authenticate!
         | 
| 16 | 
            +
                    consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    begin
         | 
| 19 | 
            +
                      signature = OAuth::Signature.build(request) do
         | 
| 20 | 
            +
                        [nil, consumer.secret]
         | 
| 21 | 
            +
                      end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                      return fail(:invalid_signature) unless signature.verify
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    rescue OAuth::Signature::UnknownSignatureMethod => e
         | 
| 26 | 
            +
                      return fail(:unknown_signature_method)
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    resource = mapping.to.find_by_opensocial_viewer_id(params[:opensocial_viewer_id])
         | 
| 30 | 
            +
                    
         | 
| 31 | 
            +
                    return fail(:resource_not_found) unless resource
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    success!(resource)
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            Warden::Strategies.add(:google_apps_open_social, Devise::Strategies::GoogleAppsOpenSocial)
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            require 'oauth'
         | 
| 2 | 
            +
            require 'simplecov'
         | 
| 3 | 
            +
            require 'active_hash'
         | 
| 4 | 
            +
            require 'action_dispatch'
         | 
| 5 | 
            +
            require 'oauth/request_proxy/rack_request'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Returns a stubbed out ActionDispatch::Request
         | 
| 8 | 
            +
            # useful for simulating requests made to rails.
         | 
| 9 | 
            +
            # see: https://github.com/rails/rails/blob/master/actionpack/test/dispatch/request_test.rb
         | 
| 10 | 
            +
            def stub_request(env = {})
         | 
| 11 | 
            +
              ip_app = ActionDispatch::RemoteIp.new(Proc.new {}, false, nil)
         | 
| 12 | 
            +
              tld_length = 1
         | 
| 13 | 
            +
              ip_app.call(env)
         | 
| 14 | 
            +
              ActionDispatch::Http::URL.tld_length = tld_length
         | 
| 15 | 
            +
              ActionDispatch::Request.new(env)
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            SimpleCov.start do
         | 
| 19 | 
            +
              add_filter "/spec/"
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            SimpleCov.minimum_coverage 95
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            require_relative '../lib/devise/strategies/google_apps_open_social'
         | 
| @@ -0,0 +1,211 @@ | |
| 1 | 
            +
            #encoding: UTF-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'spec_helper'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class Resource < ActiveHash::Base
         | 
| 6 | 
            +
              field :opensocial_viewer_id
         | 
| 7 | 
            +
              field :email
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              self.data = [{
         | 
| 10 | 
            +
                :id => 1,
         | 
| 11 | 
            +
                :opensocial_viewer_id => '117960006926679364326',
         | 
| 12 | 
            +
                :email => 'bencoe@gmail.com'
         | 
| 13 | 
            +
              }]
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            describe Devise::Strategies::GoogleAppsOpenSocial do
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              describe "valid?" do
         | 
| 20 | 
            +
                
         | 
| 21 | 
            +
                it "should return true if xoauth_public_key is set, and equal to Google's certificate name" do
         | 
| 22 | 
            +
                  Devise::Strategies::GoogleAppsOpenSocial.any_instance
         | 
| 23 | 
            +
                    .stub(:params)
         | 
| 24 | 
            +
                    .and_return({
         | 
| 25 | 
            +
                      # Google's opensocial certificate name.
         | 
| 26 | 
            +
                      :xoauth_public_key => 'pub.1210278512.2713152949996518384.cer'
         | 
| 27 | 
            +
                    })
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  strategy = Devise::Strategies::GoogleAppsOpenSocial.new({})
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  strategy.valid?.should == true
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                it "should return false if xoauth_public_key is not set" do
         | 
| 35 | 
            +
                  Devise::Strategies::GoogleAppsOpenSocial.any_instance
         | 
| 36 | 
            +
                    .stub(:params)
         | 
| 37 | 
            +
                    .and_return({})
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  strategy = Devise::Strategies::GoogleAppsOpenSocial.new({})
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  strategy.valid?.should == false
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                it "should return false if xoauth_public_key is not Google's" do
         | 
| 45 | 
            +
                  Devise::Strategies::GoogleAppsOpenSocial.any_instance
         | 
| 46 | 
            +
                    .stub(:params)
         | 
| 47 | 
            +
                    .and_return({
         | 
| 48 | 
            +
                      # Google's opensocial certificate.
         | 
| 49 | 
            +
                      :xoauth_public_key => 'pub.9999999.2713152949996518384.cer'
         | 
| 50 | 
            +
                    })
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  strategy = Devise::Strategies::GoogleAppsOpenSocial.new({})
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  strategy.valid?.should == false
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              describe 'authenticate!' do
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                before(:each) do
         | 
| 62 | 
            +
                  Devise::Strategies::GoogleAppsOpenSocial.any_instance
         | 
| 63 | 
            +
                    .stub(:mapping)
         | 
| 64 | 
            +
                    .and_return(Struct.new(:to).new(Resource))
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                it "should return :success if request signature is valid and resource is found" do
         | 
| 68 | 
            +
                  # a captured signed-http request from Google.
         | 
| 69 | 
            +
                  request = stub_request(
         | 
| 70 | 
            +
                    "QUERY_STRING" => [
         | 
| 71 | 
            +
                      "oauth_body_hash=2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D",
         | 
| 72 | 
            +
                      "opensocial_owner_id=117960006926679364326",
         | 
| 73 | 
            +
                      "&opensocial_viewer_id=117960006926679364326",
         | 
| 74 | 
            +
                      "opensocial_app_id=109107117966654434528",
         | 
| 75 | 
            +
                      "opensocial_app_url=http%3A%2F%2Fevening-scrubland-7346.herokuapp.com%2Fcontextual_gadget%2Fspec.xml",
         | 
| 76 | 
            +
                      "xoauth_signature_publickey=pub.1210278512.2713152949996518384.cer",
         | 
| 77 | 
            +
                      "xoauth_public_key=pub.1210278512.2713152949996518384.cer",
         | 
| 78 | 
            +
                      "oauth_version=1.0",
         | 
| 79 | 
            +
                      "oauth_timestamp=1382907117",
         | 
| 80 | 
            +
                      "oauth_nonce=6282976860977374235",
         | 
| 81 | 
            +
                      "opensocial_container=http%3A%2F%2Fmail.google.com",
         | 
| 82 | 
            +
                      "oauth_consumer_key=www.google.com",
         | 
| 83 | 
            +
                      "oauth_signature_method=RSA-SHA1",
         | 
| 84 | 
            +
                      "oauth_signature=gmpNELGjDpp1%2BdMRB6CySdkDu25uE1JzhOZkoShfyF1VEgA8r0lrAC2bwABTyzh5r1VP0n17mo5yO%2FBMst%2FgpgYKu%2Fl9uXI1McU9jT3t590gJioE7hmwbdwLL0EzEWWJvZMJILTUBMb%2B3%2B2GnnBGjFBP3K3PzW0ZC5A%2BxEea%2BSI%3D"
         | 
| 85 | 
            +
                    ].join('&'),
         | 
| 86 | 
            +
                    "REQUEST_METHOD" => "GET",
         | 
| 87 | 
            +
                    "HTTP_HOST" => "evening-scrubland-7346.herokuapp.com",
         | 
| 88 | 
            +
                    "PATH_INFO"=>"/public",
         | 
| 89 | 
            +
                    "action_dispatch.request.parameters" => {
         | 
| 90 | 
            +
                      :opensocial_viewer_id => "117960006926679364326"
         | 
| 91 | 
            +
                    }
         | 
| 92 | 
            +
                  )
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                  Devise::Strategies::GoogleAppsOpenSocial.any_instance
         | 
| 95 | 
            +
                    .stub(:request)
         | 
| 96 | 
            +
                    .and_return(request)
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                  strategy = Devise::Strategies::GoogleAppsOpenSocial.new({})
         | 
| 99 | 
            +
                  strategy.authenticate!.should == :success
         | 
| 100 | 
            +
                end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                it "should return :failure if opensocial_viewer_id is not found" do
         | 
| 103 | 
            +
                    request = stub_request(
         | 
| 104 | 
            +
                      "QUERY_STRING" => [
         | 
| 105 | 
            +
                        "oauth_body_hash=2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D",
         | 
| 106 | 
            +
                        "opensocial_owner_id=117960006926679364326",
         | 
| 107 | 
            +
                        "&opensocial_viewer_id=117960006926679364326",
         | 
| 108 | 
            +
                        "opensocial_app_id=109107117966654434528",
         | 
| 109 | 
            +
                        "opensocial_app_url=http%3A%2F%2Fevening-scrubland-7346.herokuapp.com%2Fcontextual_gadget%2Fspec.xml",
         | 
| 110 | 
            +
                        "xoauth_signature_publickey=pub.1210278512.2713152949996518384.cer",
         | 
| 111 | 
            +
                        "xoauth_public_key=pub.1210278512.2713152949996518384.cer",
         | 
| 112 | 
            +
                        "oauth_version=1.0",
         | 
| 113 | 
            +
                        "oauth_timestamp=1382907117",
         | 
| 114 | 
            +
                        "oauth_nonce=6282976860977374235",
         | 
| 115 | 
            +
                        "opensocial_container=http%3A%2F%2Fmail.google.com",
         | 
| 116 | 
            +
                        "oauth_consumer_key=www.google.com",
         | 
| 117 | 
            +
                        "oauth_signature_method=RSA-SHA1",
         | 
| 118 | 
            +
                        "oauth_signature=gmpNELGjDpp1%2BdMRB6CySdkDu25uE1JzhOZkoShfyF1VEgA8r0lrAC2bwABTyzh5r1VP0n17mo5yO%2FBMst%2FgpgYKu%2Fl9uXI1McU9jT3t590gJioE7hmwbdwLL0EzEWWJvZMJILTUBMb%2B3%2B2GnnBGjFBP3K3PzW0ZC5A%2BxEea%2BSI%3D"
         | 
| 119 | 
            +
                      ].join('&'),
         | 
| 120 | 
            +
                      "REQUEST_METHOD" => "GET",
         | 
| 121 | 
            +
                      "HTTP_HOST" => "evening-scrubland-7346.herokuapp.com",
         | 
| 122 | 
            +
                      "PATH_INFO"=>"/public",
         | 
| 123 | 
            +
                      "action_dispatch.request.parameters" => {
         | 
| 124 | 
            +
                        :opensocial_viewer_id => "99999999"
         | 
| 125 | 
            +
                      }
         | 
| 126 | 
            +
                    )
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                    Devise::Strategies::GoogleAppsOpenSocial.any_instance
         | 
| 129 | 
            +
                      .stub(:request)
         | 
| 130 | 
            +
                      .and_return(request)
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                    strategy = Devise::Strategies::GoogleAppsOpenSocial.new({})
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                    strategy.authenticate!.should == :failure
         | 
| 135 | 
            +
                end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                it "should return :failure if signature is not valid" do
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                  request = stub_request(
         | 
| 140 | 
            +
                    "QUERY_STRING" => [
         | 
| 141 | 
            +
                      "oauth_body_hash=2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D",
         | 
| 142 | 
            +
                      "opensocial_owner_id=117960006926679364326",
         | 
| 143 | 
            +
                      "&opensocial_viewer_id=117960006926679364326",
         | 
| 144 | 
            +
                      "opensocial_app_id=109107117966654434528",
         | 
| 145 | 
            +
                      "opensocial_app_url=http%3A%2F%2Fevening-scrubland-7346.herokuapp.com%2Fcontextual_gadget%2Fspec.xml",
         | 
| 146 | 
            +
                      "xoauth_signature_publickey=pub.1210278512.2713152949996518384.cer",
         | 
| 147 | 
            +
                      "xoauth_public_key=pub.1210278512.2713152949996518384.cer",
         | 
| 148 | 
            +
                      "oauth_version=1.0",
         | 
| 149 | 
            +
                      "oauth_timestamp=1382907117",
         | 
| 150 | 
            +
                      "oauth_nonce=6282976860977374235",
         | 
| 151 | 
            +
                      "opensocial_container=http%3A%2F%2Fmail.google.com",
         | 
| 152 | 
            +
                      "oauth_consumer_key=www.google.com",
         | 
| 153 | 
            +
                      "oauth_signature_method=RSA-SHA1",
         | 
| 154 | 
            +
                      "oauth_signature=gmpNELGjDpp1%2BdMRB6CySdkDu25uE1JzhOZkoShfyF1VEgA8r0lrAC2bwABTyzh5r1VP0n17mo5yO%2FBMst%2FgpgYKu%2Fl9uXI1McU9jT3t590gJioE7hmwbdwLL0EzEWWJvZMJILTUBMb%2B3%2B2GnnBGjFBP3K3PzW0ZC5A%2BxEea%2BSI%3D"
         | 
| 155 | 
            +
                    ].join('&'),
         | 
| 156 | 
            +
                    "REQUEST_METHOD" => "GET",
         | 
| 157 | 
            +
                    "HTTP_HOST" => "invalid-host-causes-invalid-signature",
         | 
| 158 | 
            +
                    "PATH_INFO"=>"/public",
         | 
| 159 | 
            +
                    "action_dispatch.request.parameters" => {
         | 
| 160 | 
            +
                      :opensocial_viewer_id => "117960006926679364326"
         | 
| 161 | 
            +
                    }
         | 
| 162 | 
            +
                  )
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                  Devise::Strategies::GoogleAppsOpenSocial.any_instance
         | 
| 165 | 
            +
                    .stub(:request)
         | 
| 166 | 
            +
                    .and_return(request)
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                  strategy = Devise::Strategies::GoogleAppsOpenSocial.new({})
         | 
| 169 | 
            +
             | 
| 170 | 
            +
                  strategy.authenticate!.should == :failure
         | 
| 171 | 
            +
                end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                it "should return :failure if signature method is not known" do
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                  request = stub_request(
         | 
| 176 | 
            +
                    "QUERY_STRING" => [
         | 
| 177 | 
            +
                      "oauth_body_hash=2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D",
         | 
| 178 | 
            +
                      "opensocial_owner_id=117960006926679364326",
         | 
| 179 | 
            +
                      "&opensocial_viewer_id=117960006926679364326",
         | 
| 180 | 
            +
                      "opensocial_app_id=109107117966654434528",
         | 
| 181 | 
            +
                      "opensocial_app_url=http%3A%2F%2Fevening-scrubland-7346.herokuapp.com%2Fcontextual_gadget%2Fspec.xml",
         | 
| 182 | 
            +
                      "xoauth_signature_publickey=pub.1210278512.2713152949996518384.cer",
         | 
| 183 | 
            +
                      "xoauth_public_key=pub.1210278512.2713152949996518384.cer",
         | 
| 184 | 
            +
                      "oauth_version=1.0",
         | 
| 185 | 
            +
                      "oauth_timestamp=1382907117",
         | 
| 186 | 
            +
                      "oauth_nonce=6282976860977374235",
         | 
| 187 | 
            +
                      "opensocial_container=http%3A%2F%2Fmail.google.com",
         | 
| 188 | 
            +
                      "oauth_consumer_key=www.google.com",
         | 
| 189 | 
            +
                      "oauth_signature_method=RSA-SHA-FAKE",
         | 
| 190 | 
            +
                      "oauth_signature=gmpNELGjDpp1%2BdMRB6CySdkDu25uE1JzhOZkoShfyF1VEgA8r0lrAC2bwABTyzh5r1VP0n17mo5yO%2FBMst%2FgpgYKu%2Fl9uXI1McU9jT3t590gJioE7hmwbdwLL0EzEWWJvZMJILTUBMb%2B3%2B2GnnBGjFBP3K3PzW0ZC5A%2BxEea%2BSI%3D"
         | 
| 191 | 
            +
                    ].join('&'),
         | 
| 192 | 
            +
                    "REQUEST_METHOD" => "GET",
         | 
| 193 | 
            +
                    "HTTP_HOST" => "evening-scrubland-7346.herokuapp.com",
         | 
| 194 | 
            +
                    "PATH_INFO"=>"/public",
         | 
| 195 | 
            +
                    "action_dispatch.request.parameters" => {
         | 
| 196 | 
            +
                      :opensocial_viewer_id => "117960006926679364326"
         | 
| 197 | 
            +
                    }
         | 
| 198 | 
            +
                  )
         | 
| 199 | 
            +
             | 
| 200 | 
            +
                  Devise::Strategies::GoogleAppsOpenSocial.any_instance
         | 
| 201 | 
            +
                    .stub(:request)
         | 
| 202 | 
            +
                    .and_return(request)
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                  strategy = Devise::Strategies::GoogleAppsOpenSocial.new({})
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                  strategy.authenticate!.should == :failure
         | 
| 207 | 
            +
                end
         | 
| 208 | 
            +
             | 
| 209 | 
            +
              end
         | 
| 210 | 
            +
             | 
| 211 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,184 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: devise_strategy_google_apps_open_social
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Yesware, Inc
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2013-10-28 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: oauth
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ! '>='
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ! '>='
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ! '>='
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ! '>='
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ! '>='
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ! '>='
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: devise
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ! '>='
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: warden
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ! '>='
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ! '>='
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: rails
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - ! '>='
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: '0'
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - ! '>='
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: '0'
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: timecop
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ! '>='
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :development
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ! '>='
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: active_hash
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ! '>='
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ! '>='
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: simplecov
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - ! '>='
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '0.7'
         | 
| 132 | 
            +
              type: :development
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - ! '>='
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '0.7'
         | 
| 139 | 
            +
            description: Adds support to devise for authenticating an OpenSocial signed request.
         | 
| 140 | 
            +
            email:
         | 
| 141 | 
            +
            - engineering@yesware.com'
         | 
| 142 | 
            +
            executables: []
         | 
| 143 | 
            +
            extensions: []
         | 
| 144 | 
            +
            extra_rdoc_files: []
         | 
| 145 | 
            +
            files:
         | 
| 146 | 
            +
            - .gitignore
         | 
| 147 | 
            +
            - .rspec
         | 
| 148 | 
            +
            - .travis.yml
         | 
| 149 | 
            +
            - Gemfile
         | 
| 150 | 
            +
            - LICENSE.txt
         | 
| 151 | 
            +
            - README.md
         | 
| 152 | 
            +
            - Rakefile
         | 
| 153 | 
            +
            - devise_strategy_google_apps_open_social.gemspec
         | 
| 154 | 
            +
            - lib/devise/strategies/google_apps_certificate.rb
         | 
| 155 | 
            +
            - lib/devise/strategies/google_apps_open_social.rb
         | 
| 156 | 
            +
            - spec/spec_helper.rb
         | 
| 157 | 
            +
            - spec/strategy_spec.rb
         | 
| 158 | 
            +
            homepage: ''
         | 
| 159 | 
            +
            licenses:
         | 
| 160 | 
            +
            - MIT
         | 
| 161 | 
            +
            metadata: {}
         | 
| 162 | 
            +
            post_install_message: 
         | 
| 163 | 
            +
            rdoc_options: []
         | 
| 164 | 
            +
            require_paths:
         | 
| 165 | 
            +
            - lib
         | 
| 166 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 167 | 
            +
              requirements:
         | 
| 168 | 
            +
              - - ! '>='
         | 
| 169 | 
            +
                - !ruby/object:Gem::Version
         | 
| 170 | 
            +
                  version: '0'
         | 
| 171 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 172 | 
            +
              requirements:
         | 
| 173 | 
            +
              - - ! '>='
         | 
| 174 | 
            +
                - !ruby/object:Gem::Version
         | 
| 175 | 
            +
                  version: '0'
         | 
| 176 | 
            +
            requirements: []
         | 
| 177 | 
            +
            rubyforge_project: 
         | 
| 178 | 
            +
            rubygems_version: 2.0.0
         | 
| 179 | 
            +
            signing_key: 
         | 
| 180 | 
            +
            specification_version: 4
         | 
| 181 | 
            +
            summary: Adds support to devise for authenticating an OpenSocial signed request.
         | 
| 182 | 
            +
            test_files:
         | 
| 183 | 
            +
            - spec/spec_helper.rb
         | 
| 184 | 
            +
            - spec/strategy_spec.rb
         |