oa-openid 0.2.5 → 0.2.6

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/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ platforms :jruby do
4
+ gem 'jruby-openssl', '~> 0.7'
5
+ end
6
+
7
+ gemspec
@@ -55,5 +55,6 @@ module OmniAuth
55
55
  module Strategies
56
56
  autoload :OpenID, 'omniauth/strategies/open_id'
57
57
  autoload :GoogleApps, 'omniauth/strategies/google_apps'
58
+ autoload :Steam, 'omniauth/strategies/steam'
58
59
  end
59
60
  end
@@ -0,0 +1,55 @@
1
+ require 'omniauth/openid'
2
+ module OmniAuth
3
+ module Strategies
4
+ class Steam < OmniAuth::Strategies::OpenID
5
+ def initialize(app, store = nil, api_key = nil, options = {}, &block)
6
+ options[:identifier] ||= "http://steamcommunity.com/openid"
7
+ options[:name] ||= 'steam'
8
+ @api_key = api_key
9
+ super(app, store, options, &block)
10
+ end
11
+
12
+ def user_info(response=nil)
13
+ player = user_hash['response']['players']['player'].first
14
+ nickname = player["personaname"]
15
+ name = player["realname"]
16
+ url = player["profileurl"]
17
+ country = player["loccountrycode"]
18
+ state = player["locstatecode"]
19
+ city = player["loccityid"]
20
+
21
+ {
22
+ 'nickname' => nickname,
23
+ 'name' => name,
24
+ 'url' => url,
25
+ 'location' => "#{city}, #{state}, #{country}"
26
+ }
27
+ end
28
+
29
+ def user_hash
30
+ # Steam provides no information back on a openid response other than a 64bit user id
31
+ # Need to use this information and make a API call to get user information from steam.
32
+ if @api_key
33
+ unless @user_hash
34
+ uri = URI.parse("http://api.steampowered.com/")
35
+ req = Net::HTTP::Get.new("#{uri.path}ISteamUser/GetPlayerSummaries/v0001/?key=#{@api_key}&steamids=#{@openid_response.display_identifier.split("/").last}")
36
+ res = Net::HTTP.start(uri.host, uri.port) {|http|
37
+ http.request(req)
38
+ }
39
+ end
40
+ @user_hash ||= MultiJson.decode(res.body)
41
+ else
42
+ {}
43
+ end
44
+ end
45
+
46
+ def auth_hash
47
+ OmniAuth::Utils.deep_merge(super, {
48
+ 'uid' => @openid_response.display_identifier.split("/").last,
49
+ 'user_info' => user_info,
50
+ 'extra' => {'user_hash' => user_hash}
51
+ })
52
+ end
53
+ end
54
+ end
55
+ end
@@ -7,7 +7,7 @@ module OmniAuth
7
7
  MINOR = 2
8
8
  end
9
9
  unless defined?(::OmniAuth::Version::PATCH)
10
- PATCH = 5
10
+ PATCH = 6
11
11
  end
12
12
  unless defined?(::OmniAuth::Version::PRE)
13
13
  PRE = nil
@@ -2,7 +2,6 @@
2
2
  require File.expand_path('../lib/omniauth/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
6
5
  gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
7
6
  gem.add_runtime_dependency 'rack-openid', '~> 1.3.1'
8
7
  gem.add_runtime_dependency 'ruby-openid-apps-discovery', '~> 1.2.0'
@@ -12,7 +11,7 @@ Gem::Specification.new do |gem|
12
11
  gem.add_development_dependency 'rspec', '~> 2.5'
13
12
  gem.add_development_dependency 'simplecov', '~> 0.4'
14
13
  gem.add_development_dependency 'webmock', '~> 1.6'
15
- gem.add_development_dependency 'yard', '~> 0.6'
14
+ gem.add_development_dependency 'yard', '~> 0.7'
16
15
  gem.add_development_dependency 'ZenTest', '~> 4.5'
17
16
  gem.name = 'oa-openid'
18
17
  gem.version = OmniAuth::Version::STRING
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oa-openid
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.5
5
+ version: 0.2.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Bleigh
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-29 00:00:00 Z
14
+ date: 2011-05-20 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: oa-core
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - "="
23
23
  - !ruby/object:Gem::Version
24
- version: 0.2.5
24
+ version: 0.2.6
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
@@ -120,7 +120,7 @@ dependencies:
120
120
  requirements:
121
121
  - - ~>
122
122
  - !ruby/object:Gem::Version
123
- version: "0.6"
123
+ version: "0.7"
124
124
  type: :development
125
125
  version_requirements: *id010
126
126
  - !ruby/object:Gem::Dependency
@@ -148,6 +148,7 @@ files:
148
148
  - .gemtest
149
149
  - .rspec
150
150
  - .yardopts
151
+ - Gemfile
151
152
  - LICENSE
152
153
  - README.rdoc
153
154
  - Rakefile
@@ -156,6 +157,7 @@ files:
156
157
  - lib/omniauth/openid/gapps.rb
157
158
  - lib/omniauth/strategies/google_apps.rb
158
159
  - lib/omniauth/strategies/open_id.rb
160
+ - lib/omniauth/strategies/steam.rb
159
161
  - lib/omniauth/version.rb
160
162
  - oa-openid.gemspec
161
163
  - spec/omniauth/strategies/open_id_spec.rb
@@ -183,11 +185,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
185
  requirements: []
184
186
 
185
187
  rubyforge_project:
186
- rubygems_version: 1.7.2
188
+ rubygems_version: 1.8.2
187
189
  signing_key:
188
190
  specification_version: 3
189
191
  summary: OpenID strategies for OmniAuth.
190
192
  test_files:
191
193
  - spec/omniauth/strategies/open_id_spec.rb
192
194
  - spec/spec_helper.rb
193
- has_rdoc: