omniauth-vkontakte 1.3.7 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +11 -0
- data/.travis.yml +13 -7
- data/Gemfile +8 -1
- data/LICENSE +21 -0
- data/README.md +33 -33
- data/Rakefile +5 -3
- data/examples/.env.example +2 -0
- data/examples/Gemfile +4 -1
- data/examples/README.md +11 -0
- data/examples/config.ru +6 -0
- data/examples/{sinatra.rb → main.rb} +9 -10
- data/lib/omniauth-vkontakte.rb +7 -3
- data/lib/omniauth/strategies/vkontakte.rb +42 -35
- data/lib/omniauth/vkontakte/version.rb +7 -0
- data/omniauth-vkontakte.gemspec +12 -10
- data/spec/omniauth/strategies/vkontakte_spec.rb +22 -18
- data/spec/spec_helper.rb +5 -3
- metadata +25 -16
- data/lib/omniauth-vkontakte/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a66fd112fb2f1d79deedab3d2f7eb3eef303e0e22f827ccdb3174fe50a7f9b8c
|
4
|
+
data.tar.gz: 1651a2707b44331710292fa786093762a3b02797067cbb2402f615b44d5aafe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72ecf8d314ae1095196f46b23e27b2408145fd25d790e66e04a4c236b0c6d26c0ead47edbe65b059cd9cf1089ce996d437dd9696a625c860d70a5812907557cd
|
7
|
+
data.tar.gz: abeaf3b11d33befae097b787e099094ca2c608391d63426de50159d52ccb72507e0038a622ceff527e3a60e8ce1542fc0b4cd2bd0b08e50b65a5efd237f24532
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
2
|
+
before_install:
|
3
|
+
- gem update bundler
|
4
|
+
- bundle --version
|
5
|
+
- gem update --system
|
6
|
+
- gem --version
|
3
7
|
rvm:
|
4
|
-
-
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
-
|
9
|
-
|
8
|
+
- 2.6.0
|
9
|
+
- 2.5.3
|
10
|
+
- 2.4.5
|
11
|
+
- 2.3.8
|
12
|
+
- jruby-head
|
13
|
+
script:
|
14
|
+
- bundle exec rspec
|
15
|
+
- bundle exec rubocop
|
data/Gemfile
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
7
|
+
gem 'rack', RUBY_VERSION < '2.2.2' ? '~> 1.6' : '>= 2.0'
|
5
8
|
gem 'rake'
|
6
9
|
|
10
|
+
group :development do
|
11
|
+
gem 'rubocop', require: false
|
12
|
+
end
|
13
|
+
|
7
14
|
group :test do
|
8
|
-
gem 'rspec', '~> 3.2'
|
9
15
|
gem 'rack-test'
|
16
|
+
gem 'rspec'
|
10
17
|
gem 'simplecov'
|
11
18
|
gem 'webmock'
|
12
19
|
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011-2019 Anton Maminov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,22 +1,40 @@
|
|
1
1
|
# OmniAuth VKontakte
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/149c0614deef469faa49e1e8ae384bd3)](https://app.codacy.com/app/mamantoha/omniauth-vkontakte?utm_source=github.com&utm_medium=referral&utm_content=mamantoha/omniauth-vkontakte&utm_campaign=Badge_Grade_Dashboard)
|
4
|
+
[![Build Status](https://travis-ci.org/mamantoha/omniauth-vkontakte.svg?branch=master)](https://travis-ci.org/mamantoha/omniauth-vkontakte)
|
4
5
|
[![Gem Version][rubygems_badge]][rubygems]
|
5
|
-
[![
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/1ea61cb860f9f6aafb4f/maintainability)](https://codeclimate.com/github/mamantoha/omniauth-vkontakte/maintainability)
|
6
7
|
|
7
8
|
This is the unofficial [OmniAuth](https://github.com/intridea/omniauth) strategy for authenticating to VKontakte via OAuth.
|
8
9
|
To use it, you'll need to sign up for an OAuth2 Application ID and Secret
|
9
10
|
on the [Vkontakte Developers Page](http://vk.com/dev).
|
10
11
|
|
11
|
-
##
|
12
|
+
## Installing
|
13
|
+
|
14
|
+
Add to your `Gemfile`:
|
12
15
|
|
13
16
|
```ruby
|
14
|
-
|
15
|
-
|
17
|
+
gem 'omniauth-vkontakte'
|
18
|
+
```
|
19
|
+
|
20
|
+
Then `bundle install`
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
`OmniAuth::Strategies::Vkontakte` is simply a Rack middleware.
|
25
|
+
|
26
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
30
|
+
provider :vkontakte, ENV['VK_API_ID'], ENV['VK_API_SECRET']
|
16
31
|
end
|
17
32
|
```
|
18
33
|
|
34
|
+
[See the example Sinatra app](https://github.com/mamantoha/omniauth-vkontakte/blob/master/examples/main.rb).
|
35
|
+
|
19
36
|
## Configuring
|
37
|
+
|
20
38
|
You can configure several options, which you pass in to the `provider` method via a `Hash`:
|
21
39
|
|
22
40
|
* `scope`: a comma-separated list of access permissions you want to request from the user. [Read the Vkontakte docs for more details](http://vk.com/dev/permissions)
|
@@ -32,14 +50,12 @@ Here's an example of a possible configuration:
|
|
32
50
|
|
33
51
|
```ruby
|
34
52
|
use OmniAuth::Builder do
|
35
|
-
provider :vkontakte, ENV['
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:image_size => 'original'
|
42
|
-
}
|
53
|
+
provider :vkontakte, ENV['VKONTAKTE_KEY'], ENV['VKONTAKTE_SECRET'],
|
54
|
+
scope: 'friends,audio,photos',
|
55
|
+
display: 'popup',
|
56
|
+
lang: 'en',
|
57
|
+
https: 1,
|
58
|
+
image_size: 'original'
|
43
59
|
end
|
44
60
|
```
|
45
61
|
|
@@ -83,17 +99,12 @@ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
|
83
99
|
|
84
100
|
The precise information available may depend on the permissions which you request.
|
85
101
|
|
86
|
-
|
87
102
|
## Supported Rubies
|
88
103
|
|
89
104
|
Tested with the following Ruby versions:
|
90
105
|
|
91
|
-
- MRI 2.3
|
92
|
-
-
|
93
|
-
- MRI 2.1
|
94
|
-
- MRI 2.0
|
95
|
-
- MRI 1.9.3
|
96
|
-
- JRUBY 1.x
|
106
|
+
- Ruby MRI (2.3.0+)
|
107
|
+
- JRuby
|
97
108
|
|
98
109
|
## Contributing to omniauth-vkontakte
|
99
110
|
|
@@ -101,20 +112,9 @@ Tested with the following Ruby versions:
|
|
101
112
|
|
102
113
|
## License
|
103
114
|
|
104
|
-
Copyright
|
105
|
-
|
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:
|
115
|
+
Copyright: 2011-2019 Anton Maminov (anton.maminov@gmail.com)
|
107
116
|
|
108
|
-
|
109
|
-
|
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
|
117
|
+
This library is distributed under the MIT license. Please see the LICENSE file.
|
114
118
|
|
115
119
|
[rubygems_badge]: http://img.shields.io/gem/v/omniauth-vkontakte.svg?style=flat
|
116
120
|
[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,9 +1,11 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/gem_tasks'
|
3
5
|
require 'rspec/core/rake_task'
|
4
6
|
|
5
|
-
desc
|
7
|
+
desc 'Run specs'
|
6
8
|
RSpec::Core::RakeTask.new
|
7
9
|
|
8
10
|
desc 'Default: run specs.'
|
9
|
-
task :
|
11
|
+
task default: :spec
|
data/examples/Gemfile
CHANGED
data/examples/README.md
ADDED
data/examples/config.ru
ADDED
@@ -1,23 +1,22 @@
|
|
1
|
-
|
2
|
-
require 'bundler'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require 'pp'
|
5
4
|
require 'sinatra'
|
6
5
|
require 'omniauth'
|
7
6
|
require 'omniauth-vkontakte'
|
8
7
|
|
8
|
+
configure { set :server, :puma }
|
9
|
+
|
9
10
|
SCOPE = 'friends,audio'
|
10
11
|
|
11
12
|
use Rack::Session::Cookie
|
12
13
|
|
13
14
|
use OmniAuth::Builder do
|
14
|
-
provider :vkontakte,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
:image_size => 'original'
|
20
|
-
}
|
15
|
+
provider :vkontakte, ENV['VKONTAKTE_KEY'], ENV['VKONTAKTE_SECRET'],
|
16
|
+
scope: SCOPE,
|
17
|
+
display: 'popup',
|
18
|
+
lang: 'en',
|
19
|
+
image_size: 'original'
|
21
20
|
end
|
22
21
|
|
23
22
|
get '/' do
|
data/lib/omniauth-vkontakte.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
|
2
|
-
require "omniauth"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
3
|
+
require 'omniauth/vkontakte/version'
|
4
|
+
require 'omniauth'
|
5
|
+
|
6
|
+
# :nodoc:
|
4
7
|
module OmniAuth
|
8
|
+
# :nodoc:
|
5
9
|
module Strategies
|
6
|
-
autoload :Vkontakte,
|
10
|
+
autoload :Vkontakte, 'omniauth/strategies/vkontakte'
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'omniauth/strategies/oauth2'
|
2
4
|
|
3
5
|
module OmniAuth
|
@@ -13,19 +15,18 @@ module OmniAuth
|
|
13
15
|
class Vkontakte < OmniAuth::Strategies::OAuth2
|
14
16
|
class NoRawData < StandardError; end
|
15
17
|
|
16
|
-
API_VERSION = '5.
|
18
|
+
API_VERSION = '5.107'
|
17
19
|
|
18
20
|
DEFAULT_SCOPE = ''
|
19
21
|
|
20
22
|
option :name, 'vkontakte'
|
21
23
|
|
22
|
-
option :client_options,
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
24
|
+
option :client_options,
|
25
|
+
site: 'https://api.vk.com/',
|
26
|
+
token_url: 'https://oauth.vk.com/access_token',
|
27
|
+
authorize_url: 'https://oauth.vk.com/authorize'
|
27
28
|
|
28
|
-
option :authorize_options, [
|
29
|
+
option :authorize_options, %i[scope display]
|
29
30
|
|
30
31
|
option :redirect_url, nil
|
31
32
|
|
@@ -34,16 +35,16 @@ module OmniAuth
|
|
34
35
|
# https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema
|
35
36
|
info do
|
36
37
|
{
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
38
|
+
name: "#{raw_info['first_name']} #{raw_info['last_name']}".strip,
|
39
|
+
nickname: raw_info['nickname'],
|
40
|
+
email: access_token.params['email'],
|
41
|
+
first_name: raw_info['first_name'],
|
42
|
+
last_name: raw_info['last_name'],
|
43
|
+
image: image_url,
|
44
|
+
location: location,
|
45
|
+
urls: {
|
45
46
|
'Vkontakte' => "http://vk.com/#{raw_info['screen_name']}"
|
46
|
-
}
|
47
|
+
}
|
47
48
|
}
|
48
49
|
end
|
49
50
|
|
@@ -57,36 +58,30 @@ module OmniAuth
|
|
57
58
|
access_token.options[:mode] = :query
|
58
59
|
access_token.options[:param_name] = :access_token
|
59
60
|
@raw_info ||= begin
|
60
|
-
|
61
|
-
:fields => info_options,
|
62
|
-
:lang => lang_option,
|
63
|
-
:https => https_option,
|
64
|
-
:v => API_VERSION,
|
65
|
-
}
|
61
|
+
result = access_token.get('/method/users.get', params: params).parsed['response']
|
66
62
|
|
67
|
-
result
|
63
|
+
raise NoRawData, result unless result.is_a?(Array) && result.first
|
68
64
|
|
69
|
-
raise NoRawData, result unless (result.is_a?(Array) and result.first)
|
70
65
|
result.first
|
71
66
|
end
|
72
67
|
end
|
73
68
|
|
74
|
-
|
75
|
-
#
|
76
|
-
# you need to set them dynamically.
|
69
|
+
# You can pass +display+, +revoke+ or +scope+ params to the auth request,
|
70
|
+
# if you need to set them dynamically.
|
77
71
|
#
|
78
72
|
# http://vk.com/dev/oauth_dialog
|
79
73
|
#
|
74
|
+
# +revoke+ revokes access and re-authorizes user.
|
80
75
|
def authorize_params
|
81
76
|
super.tap do |params|
|
82
77
|
# just a copypaste from ominauth-facebook
|
83
|
-
%w[display state scope].each do |v|
|
84
|
-
|
85
|
-
|
78
|
+
%w[display state scope revoke].each do |v|
|
79
|
+
next unless request.params[v]
|
80
|
+
|
81
|
+
params[v.to_sym] = request.params[v]
|
86
82
|
|
87
|
-
|
88
|
-
|
89
|
-
end
|
83
|
+
# to support omniauth-oauth2's auto csrf protection
|
84
|
+
session['omniauth.state'] = params[:state] if v == 'state'
|
90
85
|
end
|
91
86
|
|
92
87
|
params[:scope] ||= DEFAULT_SCOPE
|
@@ -95,15 +90,27 @@ module OmniAuth
|
|
95
90
|
|
96
91
|
private
|
97
92
|
|
93
|
+
def params
|
94
|
+
{
|
95
|
+
fields: info_options,
|
96
|
+
lang: lang_option,
|
97
|
+
https: https_option,
|
98
|
+
v: API_VERSION
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
98
102
|
def callback_url
|
99
103
|
options.redirect_url || (full_host + script_name + callback_path)
|
100
104
|
end
|
101
105
|
|
102
106
|
def info_options
|
103
107
|
# http://vk.com/dev/fields
|
104
|
-
fields = %w[
|
108
|
+
fields = %w[
|
109
|
+
nickname screen_name sex city country online bdate
|
110
|
+
photo_50 photo_100 photo_200 photo_200_orig photo_400_orig
|
111
|
+
]
|
105
112
|
fields.concat(options[:info_fields].split(',')) if options[:info_fields]
|
106
|
-
|
113
|
+
fields.join(',')
|
107
114
|
end
|
108
115
|
|
109
116
|
def lang_option
|
data/omniauth-vkontakte.gemspec
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('lib/omniauth/vkontakte/version', __dir__)
|
2
4
|
|
3
5
|
Gem::Specification.new do |gem|
|
4
|
-
gem.authors = [
|
5
|
-
gem.email = [
|
6
|
-
gem.
|
7
|
-
gem.
|
8
|
-
gem.
|
6
|
+
gem.authors = ['Anton Maminov']
|
7
|
+
gem.email = ['anton.linux@gmail.com']
|
8
|
+
gem.summary = 'Vkontakte OAuth2 Strategy for OmniAuth'
|
9
|
+
gem.homepage = 'https://github.com/mamantoha/omniauth-vkontakte'
|
10
|
+
gem.licenses = ['MIT']
|
9
11
|
|
10
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
11
13
|
gem.files = `git ls-files`.split("\n")
|
12
14
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
-
gem.name =
|
14
|
-
gem.require_paths = [
|
15
|
+
gem.name = 'omniauth-vkontakte'
|
16
|
+
gem.require_paths = ['lib']
|
15
17
|
gem.version = OmniAuth::Vkontakte::VERSION
|
16
18
|
|
17
|
-
gem.
|
19
|
+
gem.add_runtime_dependency 'omniauth-oauth2', ['>= 1.5', '<= 1.6']
|
18
20
|
end
|
@@ -1,14 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe OmniAuth::Strategies::Vkontakte do
|
6
|
-
let(:request) { double('Request', :
|
6
|
+
let(:request) { double('Request', params: {}, cookies: {}, env: {}) }
|
7
7
|
|
8
8
|
before do
|
9
9
|
OmniAuth.config.test_mode = true
|
10
10
|
end
|
11
11
|
|
12
|
+
it 'should have version' do
|
13
|
+
expect(OmniAuth::Vkontakte::VERSION).to_not be_nil
|
14
|
+
end
|
15
|
+
|
12
16
|
subject do
|
13
17
|
args = ['api_key', 'api_secret', @options || {}].compact
|
14
18
|
obj = OmniAuth::Strategies::Vkontakte.new(*args).tap do |strategy|
|
@@ -19,7 +23,7 @@ describe OmniAuth::Strategies::Vkontakte do
|
|
19
23
|
@access_token = double('OAuth2::AccessToken')
|
20
24
|
allow(obj).to receive(:access_token).and_return(@access_token)
|
21
25
|
allow(@access_token).to receive(:get).and_return(double('OAuth2::Response'))
|
22
|
-
allow(@access_token).to receive(:params).and_return(
|
26
|
+
allow(@access_token).to receive(:params).and_return('email' => raw_info_hash['email'])
|
23
27
|
obj
|
24
28
|
end
|
25
29
|
|
@@ -78,40 +82,40 @@ describe OmniAuth::Strategies::Vkontakte do
|
|
78
82
|
describe 'image_size option' do
|
79
83
|
context 'when user has an image' do
|
80
84
|
it 'should return image with size specified' do
|
81
|
-
@options = { :
|
85
|
+
@options = { image_size: 'original' }
|
82
86
|
allow(subject).to receive(:raw_info).and_return(
|
83
|
-
|
87
|
+
raw_info_hash.merge('photo_200_orig' => img_url)
|
84
88
|
)
|
85
89
|
expect(subject.info[:image]).to eq(img_url)
|
86
90
|
end
|
87
91
|
|
88
92
|
it 'should return image with size specified' do
|
89
|
-
@options = { :
|
93
|
+
@options = { image_size: 'original_x2' }
|
90
94
|
allow(subject).to receive(:raw_info).and_return(
|
91
|
-
|
95
|
+
raw_info_hash.merge('photo_400_orig' => img_url)
|
92
96
|
)
|
93
97
|
expect(subject.info[:image]).to eq(img_url)
|
94
98
|
end
|
95
99
|
|
96
100
|
it 'should return bigger image when bigger size specified' do
|
97
|
-
@options = { :
|
101
|
+
@options = { image_size: 'bigger' }
|
98
102
|
allow(subject).to receive(:raw_info).and_return(
|
99
|
-
|
103
|
+
raw_info_hash.merge('photo_100' => img_url)
|
100
104
|
)
|
101
105
|
expect(subject.info[:image]).to eq(img_url)
|
102
106
|
end
|
103
107
|
|
104
108
|
it 'should return mini image when mini size specified' do
|
105
|
-
@options = { :
|
109
|
+
@options = { image_size: 'mini' }
|
106
110
|
allow(subject).to receive(:raw_info).and_return(
|
107
|
-
|
111
|
+
raw_info_hash.merge('photo_50' => img_url)
|
108
112
|
)
|
109
113
|
expect(subject.info[:image]).to eq(img_url)
|
110
114
|
end
|
111
115
|
|
112
116
|
it 'should return normal image by default' do
|
113
117
|
allow(subject).to receive(:raw_info).and_return(
|
114
|
-
|
118
|
+
raw_info_hash.merge('photo_50' => img_url)
|
115
119
|
)
|
116
120
|
expect(subject.info[:image]).to eq(img_url)
|
117
121
|
end
|
@@ -121,8 +125,8 @@ describe OmniAuth::Strategies::Vkontakte do
|
|
121
125
|
describe 'skip_info option' do
|
122
126
|
context 'when skip info option is enabled' do
|
123
127
|
it 'should not include raw_info in extras hash' do
|
124
|
-
@options = { :
|
125
|
-
allow(subject).to receive(:raw_info).and_return(
|
128
|
+
@options = { skip_info: true }
|
129
|
+
allow(subject).to receive(:raw_info).and_return(foo: 'bar')
|
126
130
|
expect(subject.extra[:raw_info]).to eq(nil)
|
127
131
|
end
|
128
132
|
end
|
@@ -131,12 +135,12 @@ describe OmniAuth::Strategies::Vkontakte do
|
|
131
135
|
describe 'request_phase' do
|
132
136
|
context 'with no request params set and redirect_url specified' do
|
133
137
|
before do
|
134
|
-
@options = { :
|
138
|
+
@options = { redirect_url: 'http://www.example.com/auth/vkontakte/callback' }
|
135
139
|
allow(subject).to receive(:env).and_return({})
|
136
140
|
allow(subject).to receive(:request).and_return(
|
137
|
-
double('Request',
|
138
|
-
|
139
|
-
|
141
|
+
double('Request', params: {}, scheme: 'https',
|
142
|
+
url: 'https://oauth.vk.com/authorize',
|
143
|
+
cookies: {}, env: {})
|
140
144
|
)
|
141
145
|
allow(subject).to receive(:request_phase).and_return(:whatever)
|
142
146
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path(__dir__)
|
4
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
3
5
|
require 'simplecov'
|
4
6
|
SimpleCov.start
|
5
7
|
require 'rspec'
|
@@ -11,7 +13,7 @@ require 'omniauth-vkontakte'
|
|
11
13
|
RSpec.configure do |config|
|
12
14
|
config.include WebMock::API
|
13
15
|
config.include Rack::Test::Methods
|
14
|
-
config.extend OmniAuth::Test::StrategyMacros, :
|
16
|
+
config.extend OmniAuth::Test::StrategyMacros, type: :strategy
|
15
17
|
config.expect_with :rspec do |c|
|
16
18
|
c.syntax = :expect
|
17
19
|
end
|
metadata
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-vkontakte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Maminov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.5'
|
20
|
+
- - "<="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.6'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
30
|
+
- - "<="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
27
|
-
description:
|
32
|
+
version: '1.6'
|
33
|
+
description:
|
28
34
|
email:
|
29
35
|
- anton.linux@gmail.com
|
30
36
|
executables: []
|
@@ -33,20 +39,26 @@ extra_rdoc_files: []
|
|
33
39
|
files:
|
34
40
|
- ".gitignore"
|
35
41
|
- ".rspec"
|
42
|
+
- ".rubocop.yml"
|
36
43
|
- ".travis.yml"
|
37
44
|
- Gemfile
|
45
|
+
- LICENSE
|
38
46
|
- README.md
|
39
47
|
- Rakefile
|
48
|
+
- examples/.env.example
|
40
49
|
- examples/Gemfile
|
41
|
-
- examples/
|
50
|
+
- examples/README.md
|
51
|
+
- examples/config.ru
|
52
|
+
- examples/main.rb
|
42
53
|
- lib/omniauth-vkontakte.rb
|
43
|
-
- lib/omniauth-vkontakte/version.rb
|
44
54
|
- lib/omniauth/strategies/vkontakte.rb
|
55
|
+
- lib/omniauth/vkontakte/version.rb
|
45
56
|
- omniauth-vkontakte.gemspec
|
46
57
|
- spec/omniauth/strategies/vkontakte_spec.rb
|
47
58
|
- spec/spec_helper.rb
|
48
59
|
homepage: https://github.com/mamantoha/omniauth-vkontakte
|
49
|
-
licenses:
|
60
|
+
licenses:
|
61
|
+
- MIT
|
50
62
|
metadata: {}
|
51
63
|
post_install_message:
|
52
64
|
rdoc_options: []
|
@@ -63,11 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
75
|
- !ruby/object:Gem::Version
|
64
76
|
version: '0'
|
65
77
|
requirements: []
|
66
|
-
|
67
|
-
rubygems_version: 2.5.1
|
78
|
+
rubygems_version: 3.0.3
|
68
79
|
signing_key:
|
69
80
|
specification_version: 4
|
70
|
-
summary:
|
71
|
-
test_files:
|
72
|
-
- spec/omniauth/strategies/vkontakte_spec.rb
|
73
|
-
- spec/spec_helper.rb
|
81
|
+
summary: Vkontakte OAuth2 Strategy for OmniAuth
|
82
|
+
test_files: []
|