omniauth-yandex 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.swp
2
+ *.swo
3
+ Gemfile.lock
4
+ coverage
5
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # OmniAuth Yandex.ru
2
+
3
+ This gem contains the unofficial Yandex.ru OAuth2 strategy for [OmniAuth](http://github.com/intridea/omniauth).
4
+
5
+ ## Basic Usage
6
+
7
+ use OmniAuth::Builder do
8
+ provider :yandex, ENV['YANDEX_KEY'], ENV['YANDEX_PRIVATE_KEY']
9
+ end
10
+
11
+
12
+ ## Links
13
+
14
+ * http://api.yandex.ru/oauth/
15
+
16
+ ## License
17
+
18
+ Copyright (c) 2011 by Kirill Shatrov
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ require "omniauth"
2
+ require "omniauth-yandex/version"
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ autoload :Yandex, "omniauth/strategies/yandex"
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Yandex
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,72 @@
1
+ require 'omniauth/strategies/oauth2'
2
+ require 'xmlsimple'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+
7
+ # Authenticate to Yandex.ru utilizing OAuth 2.0
8
+ # http://api.yandex.ru/oauth/
9
+
10
+ class Yandex < OmniAuth::Strategies::OAuth2
11
+ option :name, "yandex"
12
+
13
+ option :client_options, {
14
+ :site => 'https://oauth.yandex.ru/',
15
+ :token_url => '/token',
16
+ :authorize_url => '/authorize'
17
+ }
18
+
19
+ uid do
20
+ raw_info[:uid]
21
+ end
22
+
23
+ info do
24
+ {
25
+ :nickname => raw_info[:name],
26
+ :email => raw_info[:email],
27
+ :name => raw_info[:name],
28
+ :image => raw_info[:photo],
29
+ :location => raw_info[:country],
30
+ :urls => {
31
+ 'Yandex' => raw_info[:yaru_profile]
32
+ }
33
+ }
34
+ end
35
+
36
+ extra do
37
+ {:raw_info => raw_info}
38
+ end
39
+
40
+ def callback_url
41
+ if options.authorize_options.respond_to? :callback_url
42
+ options.authorize_options.callback_url
43
+ else
44
+ super
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def raw_info
51
+ @raw_info ||= begin
52
+ # Get user info from Ya.ru API
53
+ # http://api.yandex.ru/yaru/doc/ref/concepts/discovery.xml
54
+ xml_data = access_token.get("https://api-yaru.yandex.ru/me/").body
55
+ data = XmlSimple.xml_in(xml_data)
56
+ {
57
+ :uid => data["id"][0],
58
+ :yaru_profile => data["link"][0]["href"],
59
+ :photo => data["link"][2]["href"],
60
+ :name => data["name"][0],
61
+ :email => data["email"][0],
62
+ :country => data["country"][0],
63
+ :city => data["city"][0],
64
+ :sex => data["sex"][0],
65
+ :skype => data["skype"][0]
66
+ }
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,23 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "omniauth-yandex/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "omniauth-yandex"
6
+ s.version = Omniauth::Yandex::VERSION
7
+ s.authors = ["Kir Shatrov"]
8
+ s.email = ["shatrov@me.com"]
9
+ s.homepage = "https://github.com/kirs/omniauth-yandex"
10
+ s.summary = %q{OmniAuth strategy for Yandex.ru}
11
+ s.description = %q{OmniAuth strategy for Yandex.ru}
12
+
13
+ s.rubyforge_project = "omniauth-yandex"
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_dependency 'omniauth', '~> 1.0'
21
+ s.add_dependency 'omniauth-oauth2', '~> 1.0'
22
+ s.add_dependency 'xml-simple'
23
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-yandex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kir Shatrov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-26 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &70210863807100 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70210863807100
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &70210863805020 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70210863805020
36
+ - !ruby/object:Gem::Dependency
37
+ name: xml-simple
38
+ requirement: &70210863803400 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70210863803400
47
+ description: OmniAuth strategy for Yandex.ru
48
+ email:
49
+ - shatrov@me.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .rspec
56
+ - .travis.yml
57
+ - Gemfile
58
+ - README.md
59
+ - Rakefile
60
+ - lib/omniauth-yandex.rb
61
+ - lib/omniauth-yandex/version.rb
62
+ - lib/omniauth/strategies/yandex.rb
63
+ - omniauth-yandex.gemspec
64
+ homepage: https://github.com/kirs/omniauth-yandex
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project: omniauth-yandex
84
+ rubygems_version: 1.8.10
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: OmniAuth strategy for Yandex.ru
88
+ test_files: []