omniauth-steam-nitrogs 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +6 -0
- data/README.md +70 -0
- data/Rakefile +1 -0
- data/lib/omniauth/strategies/steam.rb +48 -0
- data/lib/omniauth-steam-nitrogs/version.rb +5 -0
- data/lib/omniauth-steam-nitrogs.rb +2 -0
- data/omniauth-steam-nitrogs.gemspec +22 -0
- metadata +85 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# OmniAuth Steam
|
2
|
+
|
3
|
+
This gem is an OmniAuth 1.0 strategy, supporting the OpenID Steam API.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add to your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-steam'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then integrate the strategy into your middleware:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
use OmniAuth::Builder do
|
17
|
+
provider :steam, ENV['STEAM_WEB_API_KEY']
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
If you are using Rails, you may want to add it to the middleware stack:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
25
|
+
provider :steam, ENV['STEAM_WEB_API_KEY']
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
You will need to inform your steam web API key to be able to retrieve information about the authenticated user. You can request one by filling out [this form](http://steamcommunity.com/dev/apikey).
|
30
|
+
|
31
|
+
For additional information, please refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
|
32
|
+
|
33
|
+
## Authentication Hash
|
34
|
+
|
35
|
+
Here's an example of the *Authentication Hash* available in `request.env['omniauth.auth']`
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
{
|
39
|
+
:provider => "steam",
|
40
|
+
:uid => "76561198010202071",
|
41
|
+
:info => {
|
42
|
+
:nickname => "Reu",
|
43
|
+
:name => "Rodrigo Navarro",
|
44
|
+
:location => "BR",
|
45
|
+
:image => "http://media.steampowered.com/steamcommunity/public/images/avatars/3c/3c91a935dca0c1e243f3a67a198b0abea9cf6d48_medium.jpg",
|
46
|
+
:urls => {
|
47
|
+
:Profile => "http://steamcommunity.com/id/rnavarro1/"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
:credentials => {},
|
51
|
+
:extra => {
|
52
|
+
:raw_info => {
|
53
|
+
:steamid => "76561198010202071",
|
54
|
+
:communityvisibilitystate => 3,
|
55
|
+
:profilestate => 1,
|
56
|
+
:personaname => "Reu",
|
57
|
+
:lastlogoff => 1325637158,
|
58
|
+
:profileurl => "http://steamcommunity.com/id/rnavarro1/",
|
59
|
+
:avatar => "http://media.steampowered.com/steamcommunity/public/images/avatars/3c/3c91a935dca0c1e243f3a67a198b0abea9cf6d48.jpg",
|
60
|
+
:avatarmedium => "http://media.steampowered.com/steamcommunity/public/images/avatars/3c/3c91a935dca0c1e243f3a67a198b0abea9cf6d48_medium.jpg",
|
61
|
+
:avatarfull => "http://media.steampowered.com/steamcommunity/public/images/avatars/3c/3c91a935dca0c1e243f3a67a198b0abea9cf6d48_full.jpg",
|
62
|
+
:personastate => 1,
|
63
|
+
:realname => "Rodrigo Navarro",
|
64
|
+
:primaryclanid => "103582791432706194",
|
65
|
+
:timecreated => 1243031082,
|
66
|
+
:loccountrycode => "BR"
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'omniauth-openid'
|
2
|
+
module OmniAuth
|
3
|
+
module Strategies
|
4
|
+
class Steam < OmniAuth::Strategies::OpenID
|
5
|
+
args :api_key
|
6
|
+
|
7
|
+
option :api_key, nil
|
8
|
+
option :name, "steam"
|
9
|
+
option :identifier, "https://steamcommunity.com/openid"
|
10
|
+
|
11
|
+
uid { steam_id }
|
12
|
+
|
13
|
+
info do
|
14
|
+
{
|
15
|
+
"nickname" => player["personaname"],
|
16
|
+
"name" => player["realname"],
|
17
|
+
"location" => [player["loccityid"], player["locstatecode"], player["loccountrycode"]].compact.join(", "),
|
18
|
+
"image" => player["avatarmedium"],
|
19
|
+
"urls" => {
|
20
|
+
"Profile" => player["profileurl"]
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
extra do
|
26
|
+
{ "raw_info" => player }
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def raw_info
|
32
|
+
@raw_info ||= options.api_key ? MultiJson.decode(Net::HTTP.get(player_profile_uri)) : {}
|
33
|
+
end
|
34
|
+
|
35
|
+
def player
|
36
|
+
@player ||= raw_info["response"]["players"]["player"].first
|
37
|
+
end
|
38
|
+
|
39
|
+
def steam_id
|
40
|
+
openid_response.display_identifier.split("/").last
|
41
|
+
end
|
42
|
+
|
43
|
+
def player_profile_uri
|
44
|
+
URI.parse("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0001/?key=#{options.api_key}&steamids=#{steam_id}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-steam-nitrogs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-steam-nitrogs"
|
7
|
+
s.version = OmniAuth::Steam::VERSION
|
8
|
+
s.authors = ["Psiablo"]
|
9
|
+
s.email = ["psiablo@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/psiablo/omniauth-steam"
|
11
|
+
s.summary = "Steam strategy for OmniAuth"
|
12
|
+
|
13
|
+
s.rubyforge_project = "omniauth-steam-nitrogs"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_runtime_dependency "omniauth-openid"
|
21
|
+
s.add_runtime_dependency "multi_json"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-steam-nitrogs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Psiablo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-openid
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multi_json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description:
|
47
|
+
email:
|
48
|
+
- psiablo@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- lib/omniauth-steam-nitrogs.rb
|
58
|
+
- lib/omniauth-steam-nitrogs/version.rb
|
59
|
+
- lib/omniauth/strategies/steam.rb
|
60
|
+
- omniauth-steam-nitrogs.gemspec
|
61
|
+
homepage: https://github.com/psiablo/omniauth-steam
|
62
|
+
licenses: []
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project: omniauth-steam-nitrogs
|
81
|
+
rubygems_version: 1.8.24
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Steam strategy for OmniAuth
|
85
|
+
test_files: []
|