Add omniauth-steam strategy directly into plugin
Add omniauth steam strategy directly into the plugin into the file omniauth-steam.rb and require by require File.expand_path method. No more reference to omniauth-steam gem used until sources updated.
This commit is contained in:
parent
37c8c97f9b
commit
7089c00f94
|
@ -0,0 +1,60 @@
|
|||
# name: omniauth-steam
|
||||
# about: omniauth-steam
|
||||
# version: 1.0.3
|
||||
# author: Rodrigo Navarro
|
||||
|
||||
require 'omniauth-openid'
|
||||
require 'multi_json'
|
||||
|
||||
module OmniAuth
|
||||
module Strategies
|
||||
class Steam < OmniAuth::Strategies::OpenID
|
||||
args :api_key
|
||||
|
||||
option :api_key, nil
|
||||
option :name, "steam"
|
||||
option :identifier, "http://steamcommunity.com/openid"
|
||||
|
||||
uid { steam_id }
|
||||
|
||||
info do
|
||||
{
|
||||
"nickname" => player["personaname"],
|
||||
"name" => player["realname"],
|
||||
"location" => [player["loccityid"], player["locstatecode"], player["loccountrycode"]].compact.join(", "),
|
||||
"image" => player["avatarmedium"],
|
||||
"urls" => {
|
||||
"Profile" => player["profileurl"],
|
||||
"FriendList" => friend_list_url
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
extra do
|
||||
{ "raw_info" => player }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def raw_info
|
||||
@raw_info ||= options.api_key ? MultiJson.decode(Net::HTTP.get(player_profile_uri)) : {}
|
||||
end
|
||||
|
||||
def player
|
||||
@player ||= raw_info["response"]["players"].first
|
||||
end
|
||||
|
||||
def steam_id
|
||||
openid_response.display_identifier.split("/").last
|
||||
end
|
||||
|
||||
def player_profile_uri
|
||||
URI.parse("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=#{options.api_key}&steamids=#{steam_id}")
|
||||
end
|
||||
|
||||
def friend_list_url
|
||||
URI.parse("http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=#{options.api_key}&steamid=#{steam_id}&relationship=friend")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +1,9 @@
|
|||
# name: Steam authentication with Discourse
|
||||
# about: Authenticate with Discourse with Steam
|
||||
# version: 0.2.0
|
||||
# version: 0.3.0
|
||||
# author: J. de Faye, Sam Saffron
|
||||
|
||||
gem 'omniauth-steam', '1.0.3', git: 'https://github.com/reu/omniauth-steam.git'
|
||||
require File.expand_path('../omniauth-steam.rb', __FILE__)
|
||||
|
||||
class SteamAuthenticator < ::Auth::Authenticator
|
||||
|
||||
|
|
Loading…
Reference in New Issue