omniauth-vkontakte 1.3.6 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79997d8ef6bc7d287e6e508de3cfcdaf9624f77c
4
- data.tar.gz: abf92173017bfcd7f6ca215f430787362566fe2c
3
+ metadata.gz: 2e06373ee4e154f6e293faa83da80796505da615
4
+ data.tar.gz: 0797f013d01ae1cd9612ccd50a90b68a9eaea100
5
5
  SHA512:
6
- metadata.gz: de6e4aeee44d6843c38b4608fa7e1363bd413ab1d99d3e3bc7a107620e4e3b89e288a323529c9e4a44b9fcf21549c7e96fbfbe5b21cf3b374462059301450ad6
7
- data.tar.gz: 1ad929240913e3af7e9e9ecd1b5f6beb033d9eb9757c0cba34bae6e1acae5f9731e7ea31142b450c9c8ae062a220ec62933a293374a62bf8885251dfa58c4eab
6
+ metadata.gz: eec29dc7c8c85f5e3503291e4f3ca4b5eff0a2f1f95642b439ae37e76f8692819b816a332cb8cef33fc9850e29725f42ebab2a440fcb79468668643851999a2d
7
+ data.tar.gz: 7214c811616d5906607adcfd3b65638d60b7b3ee6c42d34f78a244f67b1b04376d77f0e0d10d7573540a2c908f1b305c1857dbfcadffed06c7dd0c2826356a2a
@@ -0,0 +1,5 @@
1
+ .ruby-version
2
+ .DS_Store
3
+ coverage
4
+ Gemfile.lock
5
+ .idea
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.8
7
+ - 2.2.4
8
+ - 2.3.0
9
+ - jruby
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+
7
+ group :test do
8
+ gem 'rspec', '~> 3.2'
9
+ gem 'rack-test'
10
+ gem 'simplecov'
11
+ gem 'webmock'
12
+ end
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # OmniAuth VKontakte
2
2
 
3
+ [![Build Status][travis_badge]][travis]
4
+ [![Gem Version][rubygems_badge]][rubygems]
5
+ [![Code Climate][codeclimate_badge]][codeclimate]
6
+
3
7
  This is the unofficial [OmniAuth](https://github.com/intridea/omniauth) strategy for authenticating to VKontakte via OAuth.
4
8
  To use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
9
  on the [Vkontakte Developers Page](http://vk.com/dev).
@@ -22,6 +26,7 @@ You can configure several options, which you pass in to the `provider` method vi
22
26
  * `info_fields`: specify which fields should be added to AuthHash when
23
27
  getting the user's info. Value should be a comma-separated string as per http://vk.com/dev/fields.
24
28
  * `redirect_url`: URL where code will be passed. This URL shall be a part of the domain specified in application settings http://vk.com/dev/auth_sites.
29
+ * `https`: 1 - allows you to receive https links to photos and other media. 0 - return an http links (the default).
25
30
 
26
31
  Here's an example of a possible configuration:
27
32
 
@@ -32,6 +37,7 @@ use OmniAuth::Builder do
32
37
  :scope => 'friends,audio,photos',
33
38
  :display => 'popup',
34
39
  :lang => 'en',
40
+ :https => 1,
35
41
  :image_size => 'original'
36
42
  }
37
43
  end
@@ -66,8 +72,8 @@ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
66
72
  "nickname"=>"",
67
73
  "screen_name"=>"durov",
68
74
  "bdate"=>"10.10.1984",
69
- "city"=>"2",
70
- "country"=>"1",
75
+ "city"=>{"id"=>2, "title"=>"Санкт-Петербург"},
76
+ "country"=>{"id"=>1, "title"=>"Росiя"},
71
77
  "photo"=>"http://cs7001.vk.me/c7003/v7003079/374b/53lwetwOxD8.jpg",
72
78
  "photo_big"=>"http://cs7001.vk.me/c7003/v7003736/3a08/mEqSflTauxA.jpg",
73
79
  "online"=>1,
@@ -82,8 +88,12 @@ The precise information available may depend on the permissions which you reques
82
88
 
83
89
  Tested with the following Ruby versions:
84
90
 
85
- - MRI 2.0.0
91
+ - MRI 2.3
92
+ - MRI 2.2
93
+ - MRI 2.1
94
+ - MRI 2.0
86
95
  - MRI 1.9.3
96
+ - JRUBY 1.x
87
97
 
88
98
  ## Contributing to omniauth-vkontakte
89
99
 
@@ -91,10 +101,20 @@ Tested with the following Ruby versions:
91
101
 
92
102
  ## License
93
103
 
94
- Copyright (c) 2011-2013 Anton Maminov
104
+ Copyright (c) 2011-2016 Anton Maminov
95
105
 
96
106
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
97
107
 
98
108
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
99
109
 
100
110
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
111
+
112
+ [travis_badge]: http://img.shields.io/travis/mamantoha/omniauth-vkontakte.svg?style=flat
113
+ [travis]: https://travis-ci.org/mamantoha/omniauth-vkontakte
114
+
115
+ [rubygems_badge]: http://img.shields.io/gem/v/omniauth-vkontakte.svg?style=flat
116
+ [rubygems]: http://rubygems.org/gems/omniauth-vkontakte
117
+
118
+ [codeclimate_badge]: http://img.shields.io/codeclimate/github/mamantoha/omniauth-vkontakte.svg?style=flat
119
+ [codeclimate]: https://codeclimate.com/github/mamantoha/omniauth-vkontakte
120
+
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new
7
+
8
+ desc 'Default: run specs.'
9
+ task :default => :spec
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Vkontakte
3
- VERSION = "1.3.6"
3
+ VERSION = "1.3.7"
4
4
  end
5
5
  end
@@ -1,6 +1,4 @@
1
1
  require 'omniauth/strategies/oauth2'
2
- require 'multi_json'
3
- require 'pp'
4
2
 
5
3
  module OmniAuth
6
4
  module Strategies
@@ -36,7 +34,7 @@ module OmniAuth
36
34
  # https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema
37
35
  info do
38
36
  {
39
- :name => [raw_info['first_name'], raw_info['last_name']].map(&:strip).reject(&:empty?).join(' '),
37
+ :name => "#{raw_info['first_name']} #{raw_info['last_name']}".strip,
40
38
  :nickname => raw_info['nickname'],
41
39
  :email => access_token.params["email"],
42
40
  :first_name => raw_info['first_name'],
@@ -62,6 +60,7 @@ module OmniAuth
62
60
  params = {
63
61
  :fields => info_options,
64
62
  :lang => lang_option,
63
+ :https => https_option,
65
64
  :v => API_VERSION,
66
65
  }
67
66
 
@@ -111,6 +110,10 @@ module OmniAuth
111
110
  options[:lang] || ''
112
111
  end
113
112
 
113
+ def https_option
114
+ options[:https] || 0
115
+ end
116
+
114
117
  def image_url
115
118
  case options[:image_size]
116
119
  when 'mini'
@@ -1,10 +1,6 @@
1
1
  require File.expand_path('../lib/omniauth-vkontakte/version', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.add_dependency 'omniauth', '~> 1.0'
5
- gem.add_dependency 'omniauth-oauth2', '~> 1.1'
6
- gem.add_dependency 'multi_json'
7
-
8
4
  gem.authors = ["Anton Maminov"]
9
5
  gem.email = ["anton.linux@gmail.com"]
10
6
  gem.description = %q{Unofficial VKontakte strategy for OmniAuth 1.0}
@@ -17,4 +13,6 @@ Gem::Specification.new do |gem|
17
13
  gem.name = "omniauth-vkontakte"
18
14
  gem.require_paths = ["lib"]
19
15
  gem.version = OmniAuth::Vkontakte::VERSION
16
+
17
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
20
18
  end
@@ -0,0 +1,169 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe OmniAuth::Strategies::Vkontakte do
6
+ let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
7
+
8
+ before do
9
+ OmniAuth.config.test_mode = true
10
+ end
11
+
12
+ subject do
13
+ args = ['api_key', 'api_secret', @options || {}].compact
14
+ obj = OmniAuth::Strategies::Vkontakte.new(*args).tap do |strategy|
15
+ allow(strategy).to receive(:request) {
16
+ request
17
+ }
18
+ end
19
+ @access_token = double('OAuth2::AccessToken')
20
+ allow(obj).to receive(:access_token).and_return(@access_token)
21
+ allow(@access_token).to receive(:get).and_return(double('OAuth2::Response'))
22
+ allow(@access_token).to receive(:params).and_return({ 'email' => raw_info_hash['email'] })
23
+ obj
24
+ end
25
+
26
+ describe 'client options' do
27
+ it 'should have correct name' do
28
+ expect(subject.options.name).to eq('vkontakte')
29
+ end
30
+
31
+ it 'should have correct site' do
32
+ expect(subject.options.client_options.site).to eq('https://api.vk.com/')
33
+ end
34
+
35
+ it 'should have correct authorize url' do
36
+ expect(subject.options.client_options.authorize_url).to eq('https://oauth.vk.com/authorize')
37
+ end
38
+
39
+ it 'should have correct token url' do
40
+ expect(subject.options.client_options.token_url).to eq('https://oauth.vk.com/access_token')
41
+ end
42
+ end
43
+
44
+ describe 'info' do
45
+ before do
46
+ allow(subject).to receive(:raw_info).and_return(raw_info_hash)
47
+ end
48
+
49
+ it 'should returns the nickname' do
50
+ expect(subject.info[:nickname]).to eq(raw_info_hash['nickname'])
51
+ end
52
+
53
+ it 'should returns the name' do
54
+ expect(subject.info[:name]).to eq('Павел Дуров')
55
+ end
56
+
57
+ it 'should returns the first_name' do
58
+ expect(subject.info[:first_name]).to eq(raw_info_hash['first_name'])
59
+ end
60
+
61
+ it 'should returns the last_name' do
62
+ expect(subject.info[:last_name]).to eq(raw_info_hash['last_name'])
63
+ end
64
+
65
+ it 'should returns the email' do
66
+ expect(subject.info[:email]).to eq(raw_info_hash['email'])
67
+ end
68
+
69
+ it 'should returns the location' do
70
+ expect(subject.info[:location]).to eq('Российская Федерация, Санкт-Петербург')
71
+ end
72
+
73
+ it 'should returns the urls' do
74
+ expect(subject.info[:urls]['Vkontakte']).to eq("http://vk.com/#{raw_info_hash['screen_name']}")
75
+ end
76
+ end
77
+
78
+ describe 'image_size option' do
79
+ context 'when user has an image' do
80
+ it 'should return image with size specified' do
81
+ @options = { :image_size => 'original' }
82
+ allow(subject).to receive(:raw_info).and_return(
83
+ raw_info_hash.merge({ 'photo_200_orig' => img_url })
84
+ )
85
+ expect(subject.info[:image]).to eq(img_url)
86
+ end
87
+
88
+ it 'should return image with size specified' do
89
+ @options = { :image_size => 'original_x2' }
90
+ allow(subject).to receive(:raw_info).and_return(
91
+ raw_info_hash.merge({ 'photo_400_orig' => img_url })
92
+ )
93
+ expect(subject.info[:image]).to eq(img_url)
94
+ end
95
+
96
+ it 'should return bigger image when bigger size specified' do
97
+ @options = { :image_size => 'bigger' }
98
+ allow(subject).to receive(:raw_info).and_return(
99
+ raw_info_hash.merge({ 'photo_100' => img_url })
100
+ )
101
+ expect(subject.info[:image]).to eq(img_url)
102
+ end
103
+
104
+ it 'should return mini image when mini size specified' do
105
+ @options = { :image_size => 'mini' }
106
+ allow(subject).to receive(:raw_info).and_return(
107
+ raw_info_hash.merge({ 'photo_50' => img_url })
108
+ )
109
+ expect(subject.info[:image]).to eq(img_url)
110
+ end
111
+
112
+ it 'should return normal image by default' do
113
+ allow(subject).to receive(:raw_info).and_return(
114
+ raw_info_hash.merge({ 'photo_50' => img_url })
115
+ )
116
+ expect(subject.info[:image]).to eq(img_url)
117
+ end
118
+ end
119
+ end
120
+
121
+ describe 'skip_info option' do
122
+ context 'when skip info option is enabled' do
123
+ it 'should not include raw_info in extras hash' do
124
+ @options = { :skip_info => true }
125
+ allow(subject).to receive(:raw_info).and_return({:foo => 'bar'})
126
+ expect(subject.extra[:raw_info]).to eq(nil)
127
+ end
128
+ end
129
+ end
130
+
131
+ describe 'request_phase' do
132
+ context 'with no request params set and redirect_url specified' do
133
+ before do
134
+ @options = { :redirect_url => 'http://www.example.com/auth/vkontakte/callback' }
135
+ allow(subject).to receive(:env).and_return({})
136
+ allow(subject).to receive(:request).and_return(
137
+ double('Request', {:params => {}, :scheme => 'https',
138
+ :url => 'https://oauth.vk.com/authorize',
139
+ :cookies => {}, :env => {}})
140
+ )
141
+ allow(subject).to receive(:request_phase).and_return(:whatever)
142
+ end
143
+
144
+ it 'should not break' do
145
+ expect { subject.request_phase }.not_to raise_error
146
+ end
147
+ end
148
+ end
149
+ end
150
+
151
+ private
152
+
153
+ def img_url
154
+ 'http://cs7001.vk.me/c7003/v7003079/374b/53lwetwOxD8.jpg'
155
+ end
156
+
157
+ def raw_info_hash
158
+ {
159
+ 'screen_name' => 'foo_bar',
160
+ 'first_name' => 'Павел',
161
+ 'last_name' => 'Дуров',
162
+ 'nickname' => 'foo_bar',
163
+ 'email' => 'foo@example.com',
164
+ 'country' => { 'title' => 'Российская Федерация' },
165
+ 'city' => { 'title' => 'Санкт-Петербург' },
166
+ 'description' => 'Developer',
167
+ 'url' => 'example.com/foobar'
168
+ }
169
+ end
@@ -0,0 +1,18 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-vkontakte'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ config.expect_with :rspec do |c|
16
+ c.syntax = :expect
17
+ end
18
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-vkontakte
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Maminov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2016-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: omniauth
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: omniauth-oauth2
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +24,6 @@ dependencies:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
26
  version: '1.1'
41
- - !ruby/object:Gem::Dependency
42
- name: multi_json
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
27
  description: Unofficial VKontakte strategy for OmniAuth 1.0
56
28
  email:
57
29
  - anton.linux@gmail.com
@@ -59,6 +31,10 @@ executables: []
59
31
  extensions: []
60
32
  extra_rdoc_files: []
61
33
  files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".travis.yml"
37
+ - Gemfile
62
38
  - README.md
63
39
  - Rakefile
64
40
  - examples/Gemfile
@@ -67,6 +43,8 @@ files:
67
43
  - lib/omniauth-vkontakte/version.rb
68
44
  - lib/omniauth/strategies/vkontakte.rb
69
45
  - omniauth-vkontakte.gemspec
46
+ - spec/omniauth/strategies/vkontakte_spec.rb
47
+ - spec/spec_helper.rb
70
48
  homepage: https://github.com/mamantoha/omniauth-vkontakte
71
49
  licenses: []
72
50
  metadata: {}
@@ -86,8 +64,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
64
  version: '0'
87
65
  requirements: []
88
66
  rubyforge_project:
89
- rubygems_version: 2.4.8
67
+ rubygems_version: 2.5.1
90
68
  signing_key:
91
69
  specification_version: 4
92
70
  summary: Unofficial VKontakte strategy for OmniAuth 1.0
93
- test_files: []
71
+ test_files:
72
+ - spec/omniauth/strategies/vkontakte_spec.rb
73
+ - spec/spec_helper.rb