oa-vkontakte 0.1.3 → 0.1.4
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/.gitignore +4 -0
- data/README.rdoc +3 -3
- data/Rakefile +7 -45
- data/lib/oa-vkontakte.rb +6 -0
- data/lib/oa-vkontakte/version.rb +5 -0
- data/lib/omniauth/strategies/vkontakte_open_api.rb +17 -2
- data/oa-vkontakte.gemspec +13 -53
- data/spec/omniauth/strategires/vkontakte_open_api_spec.rb +74 -0
- data/spec/spec_helper.rb +9 -6
- metadata +32 -16
- data/VERSION +0 -1
- data/spec/spec.opts +0 -1
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
Добавить в config/initializers/omniauth.rb:
|
|
10
10
|
|
|
11
11
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
|
12
|
-
provider :vkontakte_open_api, <ID приложения>
|
|
12
|
+
provider :vkontakte_open_api, <ID приложения>, <Защищенный ключ приложения>
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
Если ещё не определен, добавить путь в config/routes.rb:
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
'user_info' => {
|
|
36
36
|
'name' => 'Nick Recobra',
|
|
37
37
|
'nickname' => 'oruen',
|
|
38
|
-
'
|
|
39
|
-
'
|
|
38
|
+
'first_name' => 'Nick',
|
|
39
|
+
'last_name' => 'Recobra',
|
|
40
40
|
'image' => 'http://cs191.vkontakte.ru/u00001/e_375bc433.jpg', # путь до вконтактовского аватара
|
|
41
41
|
'urls' => { 'Page' => 'http://vkontakte.ru/id1234567890' }
|
|
42
42
|
}
|
data/Rakefile
CHANGED
|
@@ -1,50 +1,12 @@
|
|
|
1
|
-
require '
|
|
2
|
-
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
gem.name = "oa-vkontakte"
|
|
8
|
-
gem.summary = %Q{OmniAuth extension for vkontakte.ru authentication}
|
|
9
|
-
gem.description = %Q{OmniAuth extension for vkontakte.ru authentication}
|
|
10
|
-
gem.email = "oruenu@gmail.com"
|
|
11
|
-
gem.homepage = "http://github.com/oruen/oa-vkontakte"
|
|
12
|
-
gem.authors = ["Nick Recobra"]
|
|
13
|
-
gem.rubyforge_project = "oa-vkontakte"
|
|
14
|
-
gem.add_dependency 'oa-core', '~>0.1.4'
|
|
15
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
|
16
|
-
gem.add_development_dependency "yard", ">= 0"
|
|
17
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
18
|
-
end
|
|
19
|
-
Jeweler::GemcutterTasks.new
|
|
20
|
-
Jeweler::RubyforgeTasks.new do |rubyforge|
|
|
21
|
-
rubyforge.doc_task = "yardoc"
|
|
22
|
-
end
|
|
23
|
-
rescue LoadError
|
|
24
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
require 'rake/contrib/sshpublisher'
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
25
7
|
end
|
|
26
|
-
|
|
27
|
-
require 'spec/rake/spectask'
|
|
28
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
|
29
|
-
spec.libs << 'lib' << 'spec'
|
|
30
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
|
34
|
-
spec.libs << 'lib' << 'spec'
|
|
35
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
|
36
|
-
spec.rcov = true
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
task :spec => :check_dependencies
|
|
40
|
-
|
|
41
8
|
task :default => :spec
|
|
42
9
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
YARD::Rake::YardocTask.new
|
|
46
|
-
rescue LoadError
|
|
47
|
-
task :yardoc do
|
|
48
|
-
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
|
49
|
-
end
|
|
10
|
+
require 'yard'
|
|
11
|
+
YARD::Rake::YardocTask.new do |t|
|
|
50
12
|
end
|
data/lib/oa-vkontakte.rb
CHANGED
|
@@ -4,6 +4,7 @@ require 'omniauth/strategies/vkontakte_open_api/view_helper'
|
|
|
4
4
|
module OmniAuth
|
|
5
5
|
class Configuration
|
|
6
6
|
attr_accessor :vkontakte_app_id
|
|
7
|
+
attr_accessor :vkontakte_app_key
|
|
7
8
|
end
|
|
8
9
|
end
|
|
9
10
|
|
|
@@ -13,9 +14,10 @@ module OmniAuth
|
|
|
13
14
|
include OmniAuth::Strategy
|
|
14
15
|
include ViewHelper::PageHelper
|
|
15
16
|
|
|
16
|
-
def initialize(app, app_id, options = {})
|
|
17
|
+
def initialize(app, app_id, app_key, options = {})
|
|
17
18
|
@options = options
|
|
18
19
|
OmniAuth.config.vkontakte_app_id = app_id
|
|
20
|
+
OmniAuth.config.vkontakte_app_key = app_key
|
|
19
21
|
super(app, :vkontakte)
|
|
20
22
|
end
|
|
21
23
|
|
|
@@ -24,7 +26,20 @@ module OmniAuth
|
|
|
24
26
|
def request_phase
|
|
25
27
|
Rack::Response.new(vkontakte_login_page).finish
|
|
26
28
|
end
|
|
27
|
-
|
|
29
|
+
|
|
30
|
+
def callback_phase
|
|
31
|
+
app_cookie = request.cookies["vk_app_#{OmniAuth.config.vkontakte_app_id}"]
|
|
32
|
+
return fail!(:invalid_credentials) unless app_cookie
|
|
33
|
+
args = app_cookie.split("&")
|
|
34
|
+
sig_index = args.index { |arg| arg =~ /^sig=/ }
|
|
35
|
+
return fail!(:invalid_credentials) unless sig_index
|
|
36
|
+
sig = args.delete_at(sig_index)
|
|
37
|
+
puts Digest::MD5.new.hexdigest(args.sort.join('') + OmniAuth.config.vkontakte_app_key)
|
|
38
|
+
puts sig
|
|
39
|
+
return fail!(:invalid_credentials) unless Digest::MD5.new.hexdigest(args.sort.join('') + OmniAuth.config.vkontakte_app_key) == sig[4..-1]
|
|
40
|
+
super
|
|
41
|
+
end
|
|
42
|
+
|
|
28
43
|
def auth_hash
|
|
29
44
|
OmniAuth::Utils.deep_merge(super(), {
|
|
30
45
|
'uid' => request[:uid],
|
data/oa-vkontakte.gemspec
CHANGED
|
@@ -1,65 +1,25 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "oa-vkontakte/version"
|
|
5
4
|
|
|
6
5
|
Gem::Specification.new do |s|
|
|
7
6
|
s.name = %q{oa-vkontakte}
|
|
8
|
-
s.version =
|
|
9
|
-
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
7
|
+
s.version = Oa::Vkontakte::VERSION
|
|
11
8
|
s.authors = ["Nick Recobra"]
|
|
12
|
-
s.
|
|
9
|
+
s.summary = %q{OmniAuth extension for vkontakte.ru authentication}
|
|
13
10
|
s.description = %q{OmniAuth extension for vkontakte.ru authentication}
|
|
14
11
|
s.email = %q{oruenu@gmail.com}
|
|
15
|
-
s.extra_rdoc_files = [
|
|
16
|
-
"LICENSE",
|
|
17
|
-
"README.rdoc"
|
|
18
|
-
]
|
|
19
|
-
s.files = [
|
|
20
|
-
".document",
|
|
21
|
-
".gitignore",
|
|
22
|
-
"LICENSE",
|
|
23
|
-
"README.rdoc",
|
|
24
|
-
"Rakefile",
|
|
25
|
-
"VERSION",
|
|
26
|
-
"lib/oa-vkontakte.rb",
|
|
27
|
-
"lib/omniauth/strategies/vkontakte_open_api.rb",
|
|
28
|
-
"lib/omniauth/strategies/vkontakte_open_api/view_helper.rb",
|
|
29
|
-
"lib/omniauth/vkontakte.rb",
|
|
30
|
-
"oa-vkontakte.gemspec",
|
|
31
|
-
"spec/oa-vkontakte_spec.rb",
|
|
32
|
-
"spec/spec.opts",
|
|
33
|
-
"spec/spec_helper.rb"
|
|
34
|
-
]
|
|
35
12
|
s.homepage = %q{http://github.com/oruen/oa-vkontakte}
|
|
36
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
|
37
|
-
s.require_paths = ["lib"]
|
|
38
13
|
s.rubyforge_project = %q{oa-vkontakte}
|
|
39
|
-
|
|
40
|
-
s.
|
|
41
|
-
s.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
]
|
|
45
|
-
|
|
46
|
-
if s.respond_to? :specification_version then
|
|
47
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
48
|
-
s.specification_version = 3
|
|
14
|
+
|
|
15
|
+
s.add_dependency(%q<oa-core>, ["~> 0.1.4"])
|
|
16
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
|
|
17
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
|
18
|
+
s.add_development_dependency(%q<rack-test>, ["~> 0.5.6"])
|
|
49
19
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
else
|
|
55
|
-
s.add_dependency(%q<oa-core>, ["~> 0.1.4"])
|
|
56
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
57
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
|
58
|
-
end
|
|
59
|
-
else
|
|
60
|
-
s.add_dependency(%q<oa-core>, ["~> 0.1.4"])
|
|
61
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
62
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
|
63
|
-
end
|
|
20
|
+
s.files = `git ls-files`.split("\n")
|
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
23
|
+
s.require_paths = ["lib"]
|
|
64
24
|
end
|
|
65
25
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe OmniAuth::Strategies::VkontakteOpenApi, :type => :strategy do
|
|
4
|
+
|
|
5
|
+
include OmniAuth::Test::StrategyTestCase
|
|
6
|
+
|
|
7
|
+
def strategy
|
|
8
|
+
[OmniAuth::Strategies::VkontakteOpenApi, 1983892, '6FF1PUlZfEyutJxctvtd']
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'POST /auth/vkontakte_open_api/callback с логином и паролем' do
|
|
12
|
+
before(:each) do
|
|
13
|
+
@params = {
|
|
14
|
+
'nickname' => 'oruen',
|
|
15
|
+
'first_name' => 'Nick',
|
|
16
|
+
'last_name' => 'Recobra',
|
|
17
|
+
'photo' => 'http://cs191.vkontakte.ru/u00001/e_375bc433.jpg',
|
|
18
|
+
'uid' => '1234567890'
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "неуспешный запрос" do
|
|
23
|
+
it "не должен быть успешным при отсутствии куки vk_app_<APP_ID>" do
|
|
24
|
+
clear_cookies
|
|
25
|
+
post '/auth/vkontakte/callback', @params
|
|
26
|
+
last_response.should_not be_ok
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "не должен быть успешным при невалидной куке vk_app_<APP_ID>" do
|
|
30
|
+
set_cookie "vk_app_#{OmniAuth.config.vkontakte_app_id}=expire"
|
|
31
|
+
post '/auth/vkontakte/callback', @params
|
|
32
|
+
last_response.should_not be_ok
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "успешный запрос" do
|
|
37
|
+
before(:each) do
|
|
38
|
+
strategy = nil
|
|
39
|
+
string = "expire=1271238742&mid=100172&secret=97c1e8933e&sid=549b550f608e4a4d247734941debb5e68df50a66c58dc6ee2a4f60a2&sig=372df9795fe8dd29684a2f996872457c"
|
|
40
|
+
set_cookie "vk_app_#{OmniAuth.config.vkontakte_app_id}=#{Rack::Utils::escape string}"
|
|
41
|
+
post '/auth/vkontakte/callback', @params
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "должен устанавливаться защищенный ключ" do
|
|
45
|
+
OmniAuth.config.vkontakte_app_key.should == '6FF1PUlZfEyutJxctvtd'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
it 'должен быть успешным' do
|
|
50
|
+
last_response.should be_ok
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
sets_an_auth_hash
|
|
54
|
+
|
|
55
|
+
sets_provider_to 'vkontakte'
|
|
56
|
+
|
|
57
|
+
it 'должен устанавливать параметры' do
|
|
58
|
+
hash = last_request.env['omniauth.auth']
|
|
59
|
+
hash.should == {
|
|
60
|
+
'uid' => '1234567890',
|
|
61
|
+
'provider' => 'vkontakte',
|
|
62
|
+
'user_info' => {
|
|
63
|
+
'name' => 'Nick Recobra',
|
|
64
|
+
'nickname' => 'oruen',
|
|
65
|
+
'first_name' => 'Nick',
|
|
66
|
+
'last_name' => 'Recobra',
|
|
67
|
+
'image' => 'http://cs191.vkontakte.ru/u00001/e_375bc433.jpg',
|
|
68
|
+
'urls' => { 'Page' => 'http://vkontakte.ru/id1234567890' }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
1
|
require 'rubygems'
|
|
2
|
+
require 'bundler'
|
|
3
|
+
Bundler.setup
|
|
4
|
+
require 'rspec'
|
|
5
|
+
require 'omniauth/test'
|
|
6
|
+
require 'rack/test'
|
|
4
7
|
require 'oa-vkontakte'
|
|
5
|
-
require 'spec'
|
|
6
|
-
require 'spec/autorun'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
Rspec.configure do |c|
|
|
10
|
+
c.mock_with :rspec
|
|
11
|
+
c.include Rack::Test::Methods
|
|
12
|
+
c.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
|
10
13
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oa-vkontakte
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 19
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 0.1.
|
|
9
|
+
- 4
|
|
10
|
+
version: 0.1.4
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Nick Recobra
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-
|
|
18
|
+
date: 2010-11-27 00:00:00 +03:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -40,14 +40,14 @@ dependencies:
|
|
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
41
41
|
none: false
|
|
42
42
|
requirements:
|
|
43
|
-
- -
|
|
43
|
+
- - ~>
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
hash:
|
|
45
|
+
hash: 11
|
|
46
46
|
segments:
|
|
47
|
-
- 1
|
|
48
47
|
- 2
|
|
49
|
-
-
|
|
50
|
-
|
|
48
|
+
- 1
|
|
49
|
+
- 0
|
|
50
|
+
version: 2.1.0
|
|
51
51
|
type: :development
|
|
52
52
|
version_requirements: *id002
|
|
53
53
|
- !ruby/object:Gem::Dependency
|
|
@@ -64,37 +64,52 @@ dependencies:
|
|
|
64
64
|
version: "0"
|
|
65
65
|
type: :development
|
|
66
66
|
version_requirements: *id003
|
|
67
|
+
- !ruby/object:Gem::Dependency
|
|
68
|
+
name: rack-test
|
|
69
|
+
prerelease: false
|
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
71
|
+
none: false
|
|
72
|
+
requirements:
|
|
73
|
+
- - ~>
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
hash: 7
|
|
76
|
+
segments:
|
|
77
|
+
- 0
|
|
78
|
+
- 5
|
|
79
|
+
- 6
|
|
80
|
+
version: 0.5.6
|
|
81
|
+
type: :development
|
|
82
|
+
version_requirements: *id004
|
|
67
83
|
description: OmniAuth extension for vkontakte.ru authentication
|
|
68
84
|
email: oruenu@gmail.com
|
|
69
85
|
executables: []
|
|
70
86
|
|
|
71
87
|
extensions: []
|
|
72
88
|
|
|
73
|
-
extra_rdoc_files:
|
|
74
|
-
|
|
75
|
-
- README.rdoc
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
|
|
76
91
|
files:
|
|
77
92
|
- .document
|
|
78
93
|
- .gitignore
|
|
79
94
|
- LICENSE
|
|
80
95
|
- README.rdoc
|
|
81
96
|
- Rakefile
|
|
82
|
-
- VERSION
|
|
83
97
|
- lib/oa-vkontakte.rb
|
|
98
|
+
- lib/oa-vkontakte/version.rb
|
|
84
99
|
- lib/omniauth/strategies/vkontakte_open_api.rb
|
|
85
100
|
- lib/omniauth/strategies/vkontakte_open_api/view_helper.rb
|
|
86
101
|
- lib/omniauth/vkontakte.rb
|
|
87
102
|
- oa-vkontakte.gemspec
|
|
88
103
|
- spec/oa-vkontakte_spec.rb
|
|
89
|
-
- spec/
|
|
104
|
+
- spec/omniauth/strategires/vkontakte_open_api_spec.rb
|
|
90
105
|
- spec/spec_helper.rb
|
|
91
106
|
has_rdoc: true
|
|
92
107
|
homepage: http://github.com/oruen/oa-vkontakte
|
|
93
108
|
licenses: []
|
|
94
109
|
|
|
95
110
|
post_install_message:
|
|
96
|
-
rdoc_options:
|
|
97
|
-
|
|
111
|
+
rdoc_options: []
|
|
112
|
+
|
|
98
113
|
require_paths:
|
|
99
114
|
- lib
|
|
100
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
@@ -124,4 +139,5 @@ specification_version: 3
|
|
|
124
139
|
summary: OmniAuth extension for vkontakte.ru authentication
|
|
125
140
|
test_files:
|
|
126
141
|
- spec/oa-vkontakte_spec.rb
|
|
142
|
+
- spec/omniauth/strategires/vkontakte_open_api_spec.rb
|
|
127
143
|
- spec/spec_helper.rb
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.1.3
|
data/spec/spec.opts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--color
|