omniauth-kongregate 0.0.2 → 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.
- data/README.md +10 -1
- data/lib/omniauth-kongregate/version.rb +1 -1
- data/lib/omniauth/strategies/kongregate.rb +19 -5
- metadata +24 -16
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            # OmniAuth::Kongregate
         | 
| 1 | 
            +
            # OmniAuth::Kongregate 
         | 
| 2 2 |  | 
| 3 3 | 
             
            OmniAuth strategy for [Kongregate](http://www.kongregate.com) authentication
         | 
| 4 4 |  | 
| @@ -19,11 +19,16 @@ If the token is valid, `/auth/kongregate/callback` will fire. You can get the va | |
| 19 19 | 
             
                auth = request.env['omniauth.auth']
         | 
| 20 20 | 
             
                user_id = auth.uid
         | 
| 21 21 | 
             
                username = auth.extras['username']
         | 
| 22 | 
            +
                
         | 
| 23 | 
            +
            ### Guest Access
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            Guest access (users that are not logged in on Kongregate) will result in an auto-generated, non-numeric value in `user_id` (so it won't clash with `kongregate_user_id`), prefixed with "g_", so applications have a set of temporary credentials until the user decides to authenticate.
         | 
| 22 26 |  | 
| 23 27 | 
             
            ## TODO
         | 
| 24 28 |  | 
| 25 29 | 
             
            - Display the Kongregate login form for non-authenticated users
         | 
| 26 30 |  | 
| 31 | 
            +
             | 
| 27 32 | 
             
            ## Contributing
         | 
| 28 33 |  | 
| 29 34 | 
             
            1. Fork it
         | 
| @@ -31,3 +36,7 @@ If the token is valid, `/auth/kongregate/callback` will fire. You can get the va | |
| 31 36 | 
             
            3. Commit your changes (`git commit -am 'Added some feature'`)
         | 
| 32 37 | 
             
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 33 38 | 
             
            5. Create new Pull Request
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            ## Special Thanks
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            - [pmariano](http://github.com/uken/pmariano), for implementing guest access.
         | 
| @@ -2,6 +2,7 @@ require 'omniauth' | |
| 2 2 | 
             
            require 'net/http'
         | 
| 3 3 | 
             
            require 'uri'
         | 
| 4 4 | 
             
            require 'json'
         | 
| 5 | 
            +
            require "securerandom"
         | 
| 5 6 |  | 
| 6 7 | 
             
            module OmniAuth
         | 
| 7 8 | 
             
              module Strategies
         | 
| @@ -18,7 +19,8 @@ module OmniAuth | |
| 18 19 | 
             
                  end
         | 
| 19 20 |  | 
| 20 21 | 
             
                  def callback_phase
         | 
| 21 | 
            -
                    @k_response =  | 
| 22 | 
            +
                    @k_response = guest_access? ? guest_response : kongregate_auth
         | 
| 23 | 
            +
             | 
| 22 24 | 
             
                    return fail!(:invalid_credentials) unless authenticated?
         | 
| 23 25 | 
             
                    super
         | 
| 24 26 | 
             
                  end
         | 
| @@ -29,21 +31,33 @@ module OmniAuth | |
| 29 31 |  | 
| 30 32 | 
             
                  private
         | 
| 31 33 |  | 
| 34 | 
            +
                  def guest_response
         | 
| 35 | 
            +
                    { "success" => true, "username" => "guest", "user_id" => generate_guest_user_id }
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  def generate_guest_user_id
         | 
| 39 | 
            +
                    SecureRandom.uuid
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  def guest_access?
         | 
| 43 | 
            +
                    request[:user_id] == "0"
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
             | 
| 32 46 | 
             
                  def authenticated?
         | 
| 33 47 | 
             
                    @k_response && @k_response['success']
         | 
| 34 48 | 
             
                  end
         | 
| 35 49 |  | 
| 36 | 
            -
                  def  | 
| 50 | 
            +
                  def kongregate_auth
         | 
| 37 51 | 
             
                    uri = URI.parse('http://www.kongregate.com/api/authenticate.json')
         | 
| 38 52 | 
             
                    uri.query = URI.encode_www_form({
         | 
| 39 | 
            -
                      :user_id => user_id,
         | 
| 40 | 
            -
                      :game_auth_token => game_auth_token,
         | 
| 53 | 
            +
                      :user_id => request[:user_id],
         | 
| 54 | 
            +
                      :game_auth_token => request[:game_auth_token],
         | 
| 41 55 | 
             
                      :api_key => options.api_key
         | 
| 42 56 | 
             
                    })
         | 
| 43 57 | 
             
                    begin
         | 
| 44 58 | 
             
                      response = Net::HTTP.get_response(uri)
         | 
| 45 59 | 
             
                      log :debug, "Kongregate HTTP: #{response.code} - #{response.body}"
         | 
| 46 | 
            -
                      JSON.parse | 
| 60 | 
            +
                      JSON.parse response.body
         | 
| 47 61 | 
             
                    rescue Exception => e
         | 
| 48 62 | 
             
                      fail!(:kongregate_query_error, e)
         | 
| 49 63 | 
             
                      nil
         | 
    
        metadata
    CHANGED
    
    | @@ -1,64 +1,65 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: omniauth-kongregate
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0 | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| 8 | 
            -
            - Chester / Uken Games
         | 
| 8 | 
            +
            - Chester (chesterbr) / Uken Games
         | 
| 9 | 
            +
            - Pedro Mariano (pmariano)
         | 
| 9 10 | 
             
            autorequire: 
         | 
| 10 11 | 
             
            bindir: bin
         | 
| 11 12 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 13 | 
            +
            date: 2013-02-21 00:00:00.000000000 Z
         | 
| 13 14 | 
             
            dependencies:
         | 
| 14 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 16 | 
             
              name: omniauth
         | 
| 16 17 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 18 | 
             
                none: false
         | 
| 18 19 | 
             
                requirements:
         | 
| 19 | 
            -
                - -  | 
| 20 | 
            +
                - - ~>
         | 
| 20 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version:  | 
| 22 | 
            +
                    version: 1.1.1
         | 
| 22 23 | 
             
              type: :runtime
         | 
| 23 24 | 
             
              prerelease: false
         | 
| 24 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 26 | 
             
                none: false
         | 
| 26 27 | 
             
                requirements:
         | 
| 27 | 
            -
                - -  | 
| 28 | 
            +
                - - ~>
         | 
| 28 29 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version:  | 
| 30 | 
            +
                    version: 1.1.1
         | 
| 30 31 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 32 | 
             
              name: webmock
         | 
| 32 33 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 34 | 
             
                none: false
         | 
| 34 35 | 
             
                requirements:
         | 
| 35 | 
            -
                - -  | 
| 36 | 
            +
                - - ~>
         | 
| 36 37 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            -
                    version:  | 
| 38 | 
            +
                    version: 1.9.0
         | 
| 38 39 | 
             
              type: :development
         | 
| 39 40 | 
             
              prerelease: false
         | 
| 40 41 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 42 | 
             
                none: false
         | 
| 42 43 | 
             
                requirements:
         | 
| 43 | 
            -
                - -  | 
| 44 | 
            +
                - - ~>
         | 
| 44 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            -
                    version:  | 
| 46 | 
            +
                    version: 1.9.0
         | 
| 46 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 48 | 
             
              name: rspec-rails
         | 
| 48 49 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 50 | 
             
                none: false
         | 
| 50 51 | 
             
                requirements:
         | 
| 51 | 
            -
                - -  | 
| 52 | 
            +
                - - ~>
         | 
| 52 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            -
                    version: '0'
         | 
| 54 | 
            +
                    version: '2.0'
         | 
| 54 55 | 
             
              type: :development
         | 
| 55 56 | 
             
              prerelease: false
         | 
| 56 57 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 58 | 
             
                none: false
         | 
| 58 59 | 
             
                requirements:
         | 
| 59 | 
            -
                - -  | 
| 60 | 
            +
                - - ~>
         | 
| 60 61 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: '0'
         | 
| 62 | 
            +
                    version: '2.0'
         | 
| 62 63 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 63 64 | 
             
              name: capybara
         | 
| 64 65 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -126,6 +127,7 @@ dependencies: | |
| 126 127 | 
             
            description: OmniAuth Strategy for Kongregate
         | 
| 127 128 | 
             
            email:
         | 
| 128 129 | 
             
            - chester@uken.com
         | 
| 130 | 
            +
            - pmariano@
         | 
| 129 131 | 
             
            executables: []
         | 
| 130 132 | 
             
            extensions: []
         | 
| 131 133 | 
             
            extra_rdoc_files: []
         | 
| @@ -147,15 +149,21 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 147 149 | 
             
              - - ! '>='
         | 
| 148 150 | 
             
                - !ruby/object:Gem::Version
         | 
| 149 151 | 
             
                  version: '0'
         | 
| 152 | 
            +
                  segments:
         | 
| 153 | 
            +
                  - 0
         | 
| 154 | 
            +
                  hash: -1859619691304913419
         | 
| 150 155 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 151 156 | 
             
              none: false
         | 
| 152 157 | 
             
              requirements:
         | 
| 153 158 | 
             
              - - ! '>='
         | 
| 154 159 | 
             
                - !ruby/object:Gem::Version
         | 
| 155 160 | 
             
                  version: '0'
         | 
| 161 | 
            +
                  segments:
         | 
| 162 | 
            +
                  - 0
         | 
| 163 | 
            +
                  hash: -1859619691304913419
         | 
| 156 164 | 
             
            requirements: []
         | 
| 157 165 | 
             
            rubyforge_project: 
         | 
| 158 | 
            -
            rubygems_version: 1.8. | 
| 166 | 
            +
            rubygems_version: 1.8.25
         | 
| 159 167 | 
             
            signing_key: 
         | 
| 160 168 | 
             
            specification_version: 3
         | 
| 161 169 | 
             
            summary: Allows applications to get the kongregate id and username
         |