Merging in master.
This commit is contained in:
commit
3d99fa87f8
|
@ -1,36 +1,56 @@
|
|||
## MAC OS
|
||||
.DS_Store
|
||||
|
||||
/live
|
||||
.rvmrc
|
||||
|
||||
dist/*
|
||||
|
||||
## TEXTMATE
|
||||
*.tmproj
|
||||
tmtags
|
||||
|
||||
## EMACS
|
||||
*~
|
||||
\#*
|
||||
.\#*
|
||||
|
||||
## VIM
|
||||
*.swp
|
||||
|
||||
## PROJECT::GENERAL
|
||||
coverage
|
||||
rdoc
|
||||
pkg
|
||||
tmp
|
||||
oa-live
|
||||
|
||||
## PROJECT::SPECIFIC
|
||||
!.autotest
|
||||
!.document
|
||||
!.gemtest
|
||||
!.gitignore
|
||||
!.rspec
|
||||
!.yardopts
|
||||
*.gem
|
||||
*.rbc
|
||||
*.sw[a-z]
|
||||
*.tmproj
|
||||
*.tmproject
|
||||
*.un~
|
||||
*~
|
||||
.*
|
||||
.DS_Store
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
.\#*
|
||||
._*
|
||||
.bundle
|
||||
.project
|
||||
.config
|
||||
.directory
|
||||
.elc
|
||||
.loadpath
|
||||
.project
|
||||
.redcar
|
||||
.rvmrc
|
||||
.yardoc
|
||||
doc
|
||||
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
/live
|
||||
Desktop.ini
|
||||
Gemfile.lock
|
||||
Icon?
|
||||
InstalledFiles
|
||||
Session.vim
|
||||
Thumbs.db
|
||||
\#*
|
||||
\#*\#
|
||||
_yardoc
|
||||
auto-save-list
|
||||
coverage
|
||||
dist/*
|
||||
doc
|
||||
doc/
|
||||
lib/bundler/man
|
||||
oa-live
|
||||
pkg
|
||||
pkg/*
|
||||
rdoc
|
||||
spec/reports
|
||||
test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
||||
tmtags
|
||||
tramp
|
||||
|
|
|
@ -3,5 +3,7 @@ rvm:
|
|||
- 1.8.7
|
||||
- 1.9.1
|
||||
- 1.9.2
|
||||
- jruby
|
||||
- rbx
|
||||
- ree
|
||||
- ruby-head
|
||||
|
|
8
Gemfile
8
Gemfile
|
@ -1,5 +1,13 @@
|
|||
source 'http://rubygems.org'
|
||||
|
||||
platforms :jruby do
|
||||
gem 'jruby-openssl', '~> 0.7'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'yard', :git => 'https://github.com/lsegal/yard.git'
|
||||
end
|
||||
|
||||
gemspec :path => 'oa-basic'
|
||||
gemspec :path => 'oa-core'
|
||||
gemspec :path => 'oa-enterprise'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
|
||||
Copyright (c) 2010-2011 Michael Bleigh, Erik Michaels-Ober, and Intridea, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
|
@ -11,7 +11,6 @@ To install OmniAuth, simply install the gem:
|
|||
|
||||
gem install omniauth
|
||||
|
||||
|
||||
## Continuous Integration
|
||||
[![Build Status](http://travis-ci.org/intridea/omniauth.png)](http://travis-ci.org/intridea/omniauth)
|
||||
|
||||
|
@ -43,7 +42,7 @@ OmniAuth currently supports the following external providers:
|
|||
* Mixi (credit: [kiyoshi](https://github.com/kiyoshi))
|
||||
* Netflix (credit: [caged](https://github.com/caged))
|
||||
* Qzone (credit: [quake](https://github.com/quake))
|
||||
* Rdio (via [brandonweiss](http://github.com/brandonweiss))
|
||||
* Rdio (via [brandonweiss](https://github.com/brandonweiss))
|
||||
* Renren (credit: [quake](https://github.com/quake))
|
||||
* Salesforce (via [CloudSpokes](http://www.cloudspokes.com))
|
||||
* SmugMug (credit: [pchilton](https://github.com/pchilton))
|
||||
|
@ -108,12 +107,12 @@ The `user_info` hash will automatically be populated with as much information ab
|
|||
|
||||
## Resources
|
||||
|
||||
The best place to find more information is the [OmniAuth Wiki](http://github.com/intridea/omniauth/wiki). Some specific information you might be interested in:
|
||||
The best place to find more information is the [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki). Some specific information you might be interested in:
|
||||
|
||||
* [CI Build Status](http://travis-ci.org/#!/intridea/omniauth)
|
||||
* [Roadmap](http://github.com/intridea/omniauth/wiki/Roadmap)
|
||||
* [Changelog](http://github.com/intridea/omniauth/wiki/Changelog)
|
||||
* [Report Issues](http://github.com/intridea/omniauth/issues)
|
||||
* [Roadmap](https://github.com/intridea/omniauth/wiki/Roadmap)
|
||||
* [Changelog](https://github.com/intridea/omniauth/wiki/Changelog)
|
||||
* [Report Issues](https://github.com/intridea/omniauth/issues)
|
||||
* [Mailing List](http://groups.google.com/group/omniauth)
|
||||
|
||||
## OmniAuth Core
|
3
Rakefile
3
Rakefile
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env rake
|
||||
|
||||
$:.unshift File.expand_path('..', __FILE__)
|
||||
require 'tasks/all'
|
||||
|
||||
|
@ -47,4 +49,3 @@ namespace :doc do
|
|||
task.files = PROJECTS.map{|project| "#{root}/#{project}/lib/**/*.rb"} + ['README.markdown', 'LICENSE']
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
source "http://rubygems.org"
|
||||
source 'http://rubygems.org'
|
||||
|
||||
platforms :jruby do
|
||||
gem 'jruby-openssl', '~> 0.7'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'yard', :git => 'https://github.com/lsegal/yard.git'
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
|
|
@ -3,7 +3,6 @@ require File.expand_path('../lib/omniauth/version', __FILE__)
|
|||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
|
||||
gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
|
||||
gem.add_runtime_dependency 'rest-client', '~> 1.6.0'
|
||||
gem.add_development_dependency 'maruku', '~> 0.6'
|
||||
gem.add_development_dependency 'simplecov', '~> 0.4'
|
||||
|
@ -11,7 +10,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_development_dependency 'rake', '~> 0.8'
|
||||
gem.add_development_dependency 'rspec', '~> 2.5'
|
||||
gem.add_development_dependency 'webmock', '~> 1.6'
|
||||
gem.add_development_dependency 'yard', '~> 0.6'
|
||||
# gem.add_development_dependency 'yard', '~> 0.7'
|
||||
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
||||
gem.name = 'oa-basic'
|
||||
gem.version = OmniAuth::Version::STRING
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
source "http://rubygems.org"
|
||||
source 'http://rubygems.org'
|
||||
|
||||
group :development do
|
||||
gem 'yard', :git => 'https://github.com/lsegal/yard.git'
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
|
|
@ -90,13 +90,14 @@ module OmniAuth
|
|||
|
||||
def initialize(options = {})
|
||||
options[:title] ||= "Authentication Info Required"
|
||||
options[:header_info] ||= ""
|
||||
self.options = options
|
||||
|
||||
@html = ""
|
||||
header(options[:title])
|
||||
header(options[:title],options[:header_info])
|
||||
end
|
||||
|
||||
def self.build(title=nil, &block)
|
||||
def self.build(title=nil,&block)
|
||||
form = OmniAuth::Form.new(title)
|
||||
if block.arity > 0
|
||||
yield form
|
||||
|
@ -143,13 +144,14 @@ module OmniAuth
|
|||
self
|
||||
end
|
||||
|
||||
def header(title)
|
||||
def header(title,header_info)
|
||||
@html << <<-HTML
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>#{title}</title>
|
||||
#{css}
|
||||
#{header_info}
|
||||
</head>
|
||||
<body>
|
||||
<h1>#{title}</h1>
|
||||
|
|
|
@ -99,7 +99,7 @@ module OmniAuth
|
|||
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
|
||||
@env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
|
||||
end
|
||||
redirect(callback_path)
|
||||
redirect(script_name + callback_path)
|
||||
end
|
||||
|
||||
def mock_callback_call
|
||||
|
|
|
@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_development_dependency 'rack-test', '~> 0.5'
|
||||
gem.add_development_dependency 'rake', '~> 0.8'
|
||||
gem.add_development_dependency 'rspec', '~> 2.5'
|
||||
gem.add_development_dependency 'yard', '~> 0.6'
|
||||
# gem.add_development_dependency 'yard', '~> 0.7'
|
||||
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
||||
gem.name = 'oa-core'
|
||||
gem.version = OmniAuth::Version::STRING
|
||||
|
|
|
@ -258,6 +258,11 @@ describe OmniAuth::Strategy do
|
|||
strategy.call(make_env('/AUTH/Test'))[0].should == 302
|
||||
end
|
||||
|
||||
it 'should respect SCRIPT_NAME (a.k.a. BaseURI)' do
|
||||
response = strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri'))
|
||||
response[1]['Location'].should == '/sub_uri/auth/test/callback'
|
||||
end
|
||||
|
||||
it 'should be case insensitive on callback path' do
|
||||
strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
|
||||
end
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
source "http://rubygems.org"
|
||||
source 'http://rubygems.org'
|
||||
|
||||
platforms :jruby do
|
||||
gem 'jruby-openssl', '~> 0.7'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'yard', :git => 'https://github.com/lsegal/yard.git'
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
|
|
@ -38,14 +38,21 @@ module OmniAuth
|
|||
# returns nil if given nil
|
||||
def parse_user_info(node)
|
||||
return nil if node.nil?
|
||||
node.children.inject({}) do |hash, child|
|
||||
unless child.kind_of?(Nokogiri::XML::Text) ||
|
||||
child.name == 'cas:proxies' ||
|
||||
child.name == 'proxies'
|
||||
hash[child.name.sub(/^cas:/, '')] = child.content
|
||||
hash = {}
|
||||
node.children.each do |e|
|
||||
unless e.kind_of?(Nokogiri::XML::Text) ||
|
||||
e.name == 'cas:proxies' ||
|
||||
e.name == 'proxies'
|
||||
# There are no child elements
|
||||
if e.element_children.count == 0
|
||||
hash[e.name.sub(/^cas:/, '')] = e.content
|
||||
elsif e.element_children.count
|
||||
hash[e.name.sub(/^cas:/, '')] = [] if hash[e.name.sub(/^cas:/, '')].nil?
|
||||
hash[e.name.sub(/^cas:/, '')].push parse_user_info e
|
||||
end
|
||||
end
|
||||
hash
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# finds an `<cas:authenticationSuccess>` node in
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
require File.expand_path('../lib/omniauth/version', __FILE__)
|
||||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.add_runtime_dependency 'addressable', '2.2.4'
|
||||
gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
|
||||
gem.add_runtime_dependency 'addressable', '~> 2.2.6'
|
||||
gem.add_runtime_dependency 'nokogiri', '~> 1.4.2'
|
||||
gem.add_runtime_dependency 'net-ldap', '~> 0.2.2'
|
||||
gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
|
||||
|
@ -15,7 +14,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_development_dependency 'rake', '~> 0.8'
|
||||
gem.add_development_dependency 'rspec', '~> 2.5'
|
||||
gem.add_development_dependency 'webmock', '~> 1.6'
|
||||
gem.add_development_dependency 'yard', '~> 0.6'
|
||||
# gem.add_development_dependency 'yard', '~> 0.7'
|
||||
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
||||
gem.name = 'oa-enterprise'
|
||||
gem.version = OmniAuth::Version::STRING
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
source "http://rubygems.org"
|
||||
source 'http://rubygems.org'
|
||||
|
||||
platforms :jruby do
|
||||
gem 'jruby-openssl', '~> 0.7'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'yard', :git => 'https://github.com/lsegal/yard.git'
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
|
|
@ -5,5 +5,6 @@ module OmniAuth
|
|||
autoload :WindowsLive, 'omniauth/strategies/windows_live'
|
||||
autoload :Flickr, 'omniauth/strategies/flickr'
|
||||
autoload :Yupoo, 'omniauth/strategies/yupoo'
|
||||
autoload :Ign, 'omniauth/strategies/ign'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
require 'omniauth/core'
|
||||
require 'openssl'
|
||||
|
||||
module OmniAuth
|
||||
module Strategies
|
||||
class Ign
|
||||
include OmniAuth::Strategy
|
||||
IDENTIFIER_URL_PARAMETER = ""
|
||||
|
||||
class CallbackError < StandardError
|
||||
attr_accessor :error, :error_reason
|
||||
def initialize(error, error_reason)
|
||||
self.error = error
|
||||
self.error_reason = error_reason
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(app, api_key, hostname=nil, options = {})
|
||||
options[:name] ||= "ign"
|
||||
super(app, :ign)
|
||||
@api_key = api_key
|
||||
@hostname = hostname
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def request_phase
|
||||
OmniAuth::Form.build(:title => 'IGN Authentication', :header_info=>js) do
|
||||
label_field('Identifying you with the IGN server', IDENTIFIER_URL_PARAMETER)
|
||||
end.to_response
|
||||
end
|
||||
|
||||
def callback_phase
|
||||
signature = OpenSSL::HMAC.hexdigest('sha1', @api_key, ("#{request.params["username"]}::#{request.params["timestamp"]}"))
|
||||
|
||||
raise CallbackError.new("Invalid Signature","The supplied and calculated signature did not match, user not approved.") if signature != request.params["signature"]
|
||||
|
||||
super
|
||||
rescue CallbackError => e
|
||||
fail!(:invalid_response, e)
|
||||
end
|
||||
|
||||
def auth_hash
|
||||
OmniAuth::Utils.deep_merge(super, {
|
||||
'uid' => "ign-" + request.params["username"],
|
||||
'credentials' => { 'token' => request.params["signature"] },
|
||||
'user_info' => user_info,
|
||||
'extra' => { 'user_hash' => request.params }
|
||||
})
|
||||
end
|
||||
|
||||
def user_info
|
||||
{
|
||||
'nickname' => request.params["username"],
|
||||
}
|
||||
end
|
||||
|
||||
def js
|
||||
@js = <<-JS
|
||||
$(document).ready(function() {
|
||||
$.ajax({
|
||||
url: "http://#{@hostname}/users/current.json?callback=z33k",
|
||||
type: "get",
|
||||
dataType:"jsonp",
|
||||
success: function(data) {
|
||||
if(typeof data.error == 'undefined'){
|
||||
// There is a current My IGN user
|
||||
var username = data.my_ign_username;
|
||||
var signature = data.signature;
|
||||
var timestamp = data.timestamp;
|
||||
window.location = "/auth/ign/callback?username=" +username+"&signature="+signature+"×tamp=" + timestamp;
|
||||
}
|
||||
else{
|
||||
nouser();
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
function nouser() {
|
||||
var url = "http://my.ign.com/login?r="+window.location;
|
||||
top.location = url;
|
||||
window.location = url;
|
||||
}
|
||||
JS
|
||||
"\n<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js' type='text/javascript'></script>" +
|
||||
"\n<script type='text/javascript'>#{@js}</script>" +
|
||||
"\n<style type='text/css'>button {visibility:hidden;}</style>"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,6 @@
|
|||
require File.expand_path('../lib/omniauth/version', __FILE__)
|
||||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
|
||||
gem.add_runtime_dependency 'multi_json', '~> 1.0.0'
|
||||
gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
|
||||
gem.add_runtime_dependency 'rest-client', '~> 1.6.0'
|
||||
|
@ -13,7 +12,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_development_dependency 'rspec', '~> 2.5'
|
||||
gem.add_development_dependency 'simplecov', '~> 0.4'
|
||||
gem.add_development_dependency 'webmock', '~> 1.6'
|
||||
gem.add_development_dependency 'yard', '~> 0.6'
|
||||
# gem.add_development_dependency 'yard', '~> 0.7'
|
||||
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
||||
gem.name = 'oa-more'
|
||||
gem.version = OmniAuth::Version::STRING
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
source "http://rubygems.org"
|
||||
source 'http://rubygems.org'
|
||||
|
||||
platforms :jruby do
|
||||
gem 'jruby-openssl', '~> 0.7'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'yard', :git => 'https://github.com/lsegal/yard.git'
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
|
|
@ -45,7 +45,7 @@ module OmniAuth
|
|||
|
||||
def user_info
|
||||
{
|
||||
'nickname' => user_data["link"].split('/').last,
|
||||
'nickname' => user_data["username"],
|
||||
'email' => (user_data["email"] if user_data["email"]),
|
||||
'first_name' => user_data["first_name"],
|
||||
'last_name' => user_data["last_name"],
|
||||
|
|
|
@ -40,10 +40,13 @@ module OmniAuth
|
|||
'description' => person['headline'],
|
||||
'public_profile_url' => person['public_profile_url']
|
||||
}
|
||||
hash['urls']={}
|
||||
person['member_url_resources']['member_url'].each do |url|
|
||||
hash['urls']["#{url['name']}"]=url['url']
|
||||
end
|
||||
hash['urls']={}
|
||||
member_urls = person['member_url_resources']['member_url']
|
||||
if (!member_urls.nil?) and (!member_urls.empty?)
|
||||
[member_urls].flatten.each do |url|
|
||||
hash['urls']["#{url['name']}"]=url['url']
|
||||
end
|
||||
end
|
||||
hash['urls']['LinkedIn'] = person['public_profile_url']
|
||||
hash['name'] = "#{hash['first_name']} #{hash['last_name']}"
|
||||
hash
|
||||
|
|
|
@ -80,6 +80,8 @@ module OmniAuth
|
|||
fail!(:invalid_credentials, e)
|
||||
rescue ::MultiJson::DecodeError => e
|
||||
fail!(:invalid_response, e)
|
||||
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
|
||||
fail!(:timeout, e)
|
||||
end
|
||||
|
||||
def build_access_token
|
||||
|
@ -89,7 +91,7 @@ module OmniAuth
|
|||
|
||||
def auth_hash
|
||||
credentials = {'token' => @access_token.token}
|
||||
credentials.merge('refresh_token' => @access_token.refresh_token) if @access_token.expires?
|
||||
credentials.merge!('refresh_token' => @access_token.refresh_token) if @access_token.expires?
|
||||
|
||||
OmniAuth::Utils.deep_merge(super, {'credentials' => credentials})
|
||||
end
|
||||
|
|
|
@ -29,17 +29,19 @@ module OmniAuth
|
|||
|
||||
def user_data
|
||||
# http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter
|
||||
@fields ||= ['uid', 'first_name', 'last_name', 'nickname', 'domain', 'sex', 'city', 'country', 'timezone', 'photo', 'photo_big']
|
||||
@fields ||= ['uid', 'first_name', 'last_name', 'nickname', 'domain', 'sex', 'bdate', 'city', 'country', 'timezone', 'photo', 'photo_big']
|
||||
|
||||
# http://vkontakte.ru/developers.php?o=-1&p=getProfiles
|
||||
@data ||= MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getProfiles?uid=#{@access_token['user_id']}&fields=#{@fields.join(',')}&access_token=#{@access_token.token}"))['response'][0]
|
||||
|
||||
# we need these 2 additional requests since vkontakte returns only ids of the City and Country
|
||||
# http://vkontakte.ru/developers.php?o=-17680044&p=getCities
|
||||
@city ||= MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getCities?cids=#{@data['city']}&access_token=#{@access_token.token}"))['response'].try(:[], 0).try(:[], 'name')
|
||||
cities = MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getCities?cids=#{@data['city']}&access_token=#{@access_token.token}"))['response']
|
||||
@city ||= cities.first['name'] if cities && cities.first
|
||||
|
||||
# http://vkontakte.ru/developers.php?o=-17680044&p=getCountries
|
||||
@country ||= MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getCountries?cids=#{@data['country']}&access_token=#{@access_token}"))['response'].try(:[], 0).try(:[], 'name')
|
||||
countries = MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getCountries?cids=#{@data['country']}&access_token=#{@access_token}"))['response']
|
||||
@country ||= countries.first['name'] if countries && countries.first
|
||||
end
|
||||
|
||||
def request_phase
|
||||
|
@ -49,10 +51,11 @@ module OmniAuth
|
|||
|
||||
def user_info
|
||||
{
|
||||
'firstname' => @data['first_name'],
|
||||
'first_name' => @data['first_name'],
|
||||
'last_name' => @data['last_name'],
|
||||
'name' => "#{@data['first_name']} #{@data['last_name']}",
|
||||
'nickname' => @data['nickname'],
|
||||
'birth_date' => @data['bdate'],
|
||||
'image' => @data['photo'],
|
||||
'location' => "#{@country}, #{@city}",
|
||||
'urls' => {
|
||||
|
|
|
@ -3,7 +3,6 @@ require File.expand_path('../lib/omniauth/version', __FILE__)
|
|||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.add_runtime_dependency 'faraday', '~> 0.6.1'
|
||||
gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
|
||||
gem.add_runtime_dependency 'multi_json', '~> 1.0.0'
|
||||
gem.add_runtime_dependency 'multi_xml', '~> 0.2.2'
|
||||
gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
|
||||
|
@ -16,7 +15,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_development_dependency 'rspec', '~> 2.5'
|
||||
gem.add_development_dependency 'simplecov', '~> 0.4'
|
||||
gem.add_development_dependency 'webmock', '~> 1.6'
|
||||
gem.add_development_dependency 'yard', '~> 0.6'
|
||||
# gem.add_development_dependency 'yard', '~> 0.7'
|
||||
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
||||
gem.name = 'oa-oauth'
|
||||
gem.version = OmniAuth::Version::STRING
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
source "http://rubygems.org"
|
||||
source 'http://rubygems.org'
|
||||
|
||||
platforms :jruby do
|
||||
gem 'jruby-openssl', '~> 0.7'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'yard', :git => 'https://github.com/lsegal/yard.git'
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
|
|
@ -55,5 +55,6 @@ module OmniAuth
|
|||
module Strategies
|
||||
autoload :OpenID, 'omniauth/strategies/open_id'
|
||||
autoload :GoogleApps, 'omniauth/strategies/google_apps'
|
||||
autoload :Steam, 'omniauth/strategies/steam'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
require 'omniauth/openid'
|
||||
module OmniAuth
|
||||
module Strategies
|
||||
class Steam < OmniAuth::Strategies::OpenID
|
||||
def initialize(app, store = nil, api_key = nil, options = {}, &block)
|
||||
options[:identifier] ||= "http://steamcommunity.com/openid"
|
||||
options[:name] ||= 'steam'
|
||||
@api_key = api_key
|
||||
super(app, store, options, &block)
|
||||
end
|
||||
|
||||
def user_info(response=nil)
|
||||
player = user_hash['response']['players']['player'].first
|
||||
nickname = player["personaname"]
|
||||
name = player["realname"]
|
||||
url = player["profileurl"]
|
||||
country = player["loccountrycode"]
|
||||
state = player["locstatecode"]
|
||||
city = player["loccityid"]
|
||||
|
||||
{
|
||||
'nickname' => nickname,
|
||||
'name' => name,
|
||||
'url' => url,
|
||||
'location' => "#{city}, #{state}, #{country}"
|
||||
}
|
||||
end
|
||||
|
||||
def user_hash
|
||||
# Steam provides no information back on a openid response other than a 64bit user id
|
||||
# Need to use this information and make a API call to get user information from steam.
|
||||
if @api_key
|
||||
unless @user_hash
|
||||
uri = URI.parse("http://api.steampowered.com/")
|
||||
req = Net::HTTP::Get.new("#{uri.path}ISteamUser/GetPlayerSummaries/v0001/?key=#{@api_key}&steamids=#{@openid_response.display_identifier.split("/").last}")
|
||||
res = Net::HTTP.start(uri.host, uri.port) {|http|
|
||||
http.request(req)
|
||||
}
|
||||
end
|
||||
@user_hash ||= MultiJson.decode(res.body)
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
def auth_hash
|
||||
OmniAuth::Utils.deep_merge(super, {
|
||||
'uid' => @openid_response.display_identifier.split("/").last,
|
||||
'user_info' => user_info,
|
||||
'extra' => {'user_hash' => user_hash}
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,6 @@
|
|||
require File.expand_path('../lib/omniauth/version', __FILE__)
|
||||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
|
||||
gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
|
||||
gem.add_runtime_dependency 'rack-openid', '~> 1.3.1'
|
||||
gem.add_runtime_dependency 'ruby-openid-apps-discovery', '~> 1.2.0'
|
||||
|
@ -12,7 +11,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_development_dependency 'rspec', '~> 2.5'
|
||||
gem.add_development_dependency 'simplecov', '~> 0.4'
|
||||
gem.add_development_dependency 'webmock', '~> 1.6'
|
||||
gem.add_development_dependency 'yard', '~> 0.6'
|
||||
# gem.add_development_dependency 'yard', '~> 0.7'
|
||||
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
||||
gem.name = 'oa-openid'
|
||||
gem.version = OmniAuth::Version::STRING
|
||||
|
|
|
@ -5,16 +5,16 @@ Gem::Specification.new do |gem|
|
|||
%w(oa-core oa-oauth oa-identity oa-basic oa-openid oa-enterprise oa-more).each do |subgem|
|
||||
gem.add_runtime_dependency subgem, OmniAuth::Version::STRING
|
||||
end
|
||||
gem.name = 'omniauth'
|
||||
gem.version = OmniAuth::Version::STRING
|
||||
gem.summary = %q{Rack middleware for standardized multi-provider authentication.}
|
||||
gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
|
||||
gem.description = %q{OmniAuth is an authentication framework that that separates the concept of authentiation from the concept of identity, providing simple hooks for any application to have one or multiple authentication providers for a user.}
|
||||
gem.email = ['michael@intridea.com', 'sferik@gmail.com']
|
||||
gem.homepage = 'http://github.com/intridea/omniauth'
|
||||
gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
|
||||
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
||||
gem.files = `git ls-files`.split("\n")
|
||||
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||
gem.homepage = 'http://github.com/intridea/omniauth'
|
||||
gem.name = 'omniauth'
|
||||
gem.require_paths = ['lib']
|
||||
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
|
||||
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
|
||||
gem.summary = %q{Rack middleware for standardized multi-provider authentication.}
|
||||
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||
gem.version = OmniAuth::Version::STRING
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue