omniauth-mail_ru 1.1.0 → 1.2.0

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
- SHA256:
3
- metadata.gz: 4443bb97ff026aa10df7700596b0177dfd8599ed660e5b7f77b483def1e800bc
4
- data.tar.gz: b8dcab96ae5729a6f1ff8389ba5f1752e256e19c7d7ef9fa2ba8186e042134e9
2
+ SHA1:
3
+ metadata.gz: 362190443dee58ae4ad91902961735446a896339
4
+ data.tar.gz: bf0d3ef6af83ab2a964fb80ec9b697ad411ef42c
5
5
  SHA512:
6
- metadata.gz: fa7ec35b215d200aa65b095af9191c7339c75f3131526eb3d8f1cb304ea10f63fdd2a61b7fb85ded75dd4a6180401403a7d01795b8f44b04aa17ea99d6e699e3
7
- data.tar.gz: 14b7d3666fd9ead84b70da5ed03d40812f17e5658250f4540304a7e2be1febb9164bceccd2b4cc3f2d964c20d7d737854c0e221683eb37830d3017cc0c604807
6
+ metadata.gz: 0bccfce146b862dc05c20093d354a6e5afc5d64d2d5e1c40f7b44bf5edc52c5195e34fe7498dc977ffd52458f9208693a4d227b7d67866c6c705ce2e99e92658
7
+ data.tar.gz: 440756d8b93047da1099d0826760473d817c34ed830c1f84bc9cb46e71ab65407f64f18c7506119488e7644b56597822b6073bcb439678da88e7900dfb40c9c6
data/.gitignore CHANGED
File without changes
@@ -1,22 +1,4 @@
1
- ClassLength:
1
+ Style/BracesAroundHashParameters:
2
2
  Enabled: false
3
- Layout/IndentHeredoc:
4
- Enabled: false
5
- Metrics/AbcSize:
6
- Enabled: false
7
- Metrics/BlockLength:
8
- ExcludedMethods: ['describe', 'context']
9
- Metrics/CyclomaticComplexity:
10
- Enabled: false
11
- Metrics/LineLength:
12
- Enabled: false
13
- Metrics/MethodLength:
14
- Enabled: false
15
- Metrics/PerceivedComplexity:
16
- Enabled: false
17
- Naming:
18
- Enabled: false
19
- Style/MutableConstant:
20
- Enabled: false
21
- Gemspec/RequiredRubyVersion:
3
+ Naming/FileName:
22
4
  Enabled: false
data/Gemfile CHANGED
File without changes
File without changes
data/README.md CHANGED
@@ -19,7 +19,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
19
19
  end
20
20
  ```
21
21
 
22
- Replace `"API_KEY"` and `"PRIVATE_KEY"` with the appropriate values you obtained (http://api.mail.ru).
22
+ Replace `"API_KEY"` and `"PRIVATE_KEY"` with the appropriate values you obtained (https://oauth.mail.ru/app).
23
23
 
24
24
  ## Authentication Hash
25
25
  An example auth hash available in `request.env['omniauth.auth']`:
@@ -29,57 +29,19 @@ An example auth hash available in `request.env['omniauth.auth']`:
29
29
  provider: 'mail_ru',
30
30
  uid: '1111111111',
31
31
  info: {
32
- name: 'John Smith',
33
- email: 'john@mail.ru',
34
- nickname: 'JohnS',
35
- first_name: 'John',
36
- last_name: 'Smith',
37
- image: 'http://avt.appsmail.ru/mail/john/_avatar50',
38
- urls: {
39
- 'Mailru' => 'http://my.mail.ru/mail/john/'
40
- }
32
+ gender: "m",
33
+ name: "Алексей Иванов",
34
+ locale: "ru_RU",
35
+ first_name: "Алексей",
36
+ last_name: "Иванов",
37
+ email: "alex@ivanov.ru",
38
+ image: "https://...."
41
39
  },
42
40
  credentials: {
43
41
  token: '4ec9286c2f...',
44
42
  refresh_token: '351456424ad7c5...',
45
43
  expires_at: 1411054463,
46
44
  expires: true
47
- },
48
- extra: {
49
- raw_info: {
50
- pic_50: 'http://avt.appsmail.ru/mail/john/_avatar50',
51
- friends_count: 256,
52
- show_age: 1,
53
- has_photosafe: 0,
54
- nick: 'JohnS',
55
- is_friend: 0,
56
- is_online: 1,
57
- has_pic: 1,
58
- email: 'john@mail.ru',
59
- pic_190: 'http://avt.appsmail.ru/mail/john/_avatar190',
60
- referer_id: '',
61
- pic_32: 'http://avt.appsmail.ru/mail/john/_avatar32',
62
- referer_type: '',
63
- last_visit: '1410961776',
64
- uid: '1111111111',
65
- app_installed: 1,
66
- status_text: '',
67
- pic_22: 'http://avt.appsmail.ru/mail/john/_avatar22',
68
- age: 25,
69
- last_name: 'Smith',
70
- is_verified: 0,
71
- pic_big: 'http://avt.appsmail.ru/mail/john/_avatarbig',
72
- vip: 0,
73
- birthday: '01.01.1901',
74
- link: 'http://my.mail.ru/mail/john/',
75
- pic_128: 'http://avt.appsmail.ru/mail/john/_avatar128',
76
- sex: 0,
77
- pic: 'http://avt.appsmail.ru/mail/john/_avatar',
78
- pic_small: 'http://avt.appsmail.ru/mail/john/_avatarsmall',
79
- pic_180: 'http://avt.appsmail.ru/mail/john/_avatar180',
80
- first_name: 'John',
81
- pic_40: 'http://avt.appsmail.ru/mail/john/_avatar40?1229336384'
82
- }
83
45
  }
84
46
  }
85
47
 
data/Rakefile CHANGED
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module MailRu
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
@@ -4,26 +4,29 @@ module OmniAuth
4
4
  module Strategies
5
5
  # Authentication strategy for connecting with Mail.ru OAuth 2.0
6
6
  class MailRu < OmniAuth::Strategies::OAuth2
7
+ DEFAULT_SCOPE = 'userinfo'
8
+
7
9
  option :name, 'mail_ru'
8
10
 
9
- option :client_options,
10
- site: 'https://connect.mail.ru',
11
- token_url: '/oauth/token',
12
- authorize_url: '/oauth/authorize'
11
+ option :client_options, {
12
+ site: 'https://oauth.mail.ru',
13
+ token_url: '/token',
14
+ authorize_url: '/login'
15
+ }
16
+
17
+ option :auth_token_params, { mode: :query }
13
18
 
14
- uid { access_token.params['x_mailru_vid'] }
19
+ uid { raw_info['email'] }
15
20
 
16
21
  info do
17
22
  {
18
- name: [raw_info['first_name'], raw_info['last_name']].join(' ').strip,
23
+ name: raw_info['name'],
19
24
  email: raw_info['email'],
20
- nickname: raw_info['nick'],
25
+ locale: raw_info['locale'],
26
+ gender: raw_info['gender'],
21
27
  first_name: raw_info['first_name'],
22
28
  last_name: raw_info['last_name'],
23
- image: raw_info['has_pic'].to_i == 1 ? (raw_info['pic_50'] || raw_info['pic_small']) : nil,
24
- urls: {
25
- 'Mailru' => raw_info['link']
26
- }
29
+ image: raw_info['image']
27
30
  }
28
31
  end
29
32
 
@@ -34,30 +37,19 @@ module OmniAuth
34
37
  end
35
38
 
36
39
  def raw_info
37
- @raw_info ||= access_token.get('https://www.appsmail.ru/platform/api', params: info_params).parsed.first
40
+ @raw_info ||= access_token.get('https://oauth.mail.ru/userinfo').parsed
38
41
  end
39
42
 
40
- private
41
-
42
- def callback_url
43
- full_host + script_name + callback_path
43
+ def authorize_params
44
+ super.tap do |params|
45
+ params[:scope] ||= DEFAULT_SCOPE
46
+ end
44
47
  end
45
48
 
46
- def info_params
47
- params = {
48
- app_id: options.client_id,
49
- method: 'users.getInfo',
50
- secure: 1,
51
- session_key: access_token.token
52
- }
53
- params[:sig] = signature(params)
54
-
55
- params
56
- end
49
+ private
57
50
 
58
- def signature(params)
59
- params = params.sort.reduce([]) { |m, (key, value)| m.push("#{key}=#{value}") }.join
60
- Digest::MD5.hexdigest([params, options.client_secret].join)
51
+ def callback_url
52
+ options[:redirect_uri] || (full_host + script_name + callback_path)
61
53
  end
62
54
  end
63
55
  end
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'omniauth/mail_ru/version'
4
4
 
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'omniauth-mail_ru'
7
7
  spec.version = OmniAuth::MailRu::VERSION
8
8
  spec.authors = ['Andrey Skuryatin']
9
- spec.email = ['andrey.skuryatin@gmai.com']
9
+ spec.email = ['andrey.skuryatin@gmail.com']
10
10
  spec.summary = 'OmniAuth strategy for Mail.ru'
11
11
  spec.description = 'OmniAuth strategy for Mail.ru'
12
12
  spec.homepage = 'https://github.com/andrey-skat/omniauth-mail_ru'
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency 'omniauth-oauth2', '~> 1.0'
21
- spec.add_development_dependency 'rake', '~> 12.0'
22
- spec.add_development_dependency 'rspec', '~> 3.6'
20
+ spec.add_dependency 'omniauth-oauth2', '>= 1.0'
21
+ spec.add_development_dependency 'rake', '>= 12.0'
22
+ spec.add_development_dependency 'rspec', '>= 3.6'
23
23
  spec.add_development_dependency 'rubocop', '~> 0.49'
24
24
  end
File without changes
File without changes
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-mail_ru
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Skuryatin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-08 00:00:00.000000000 Z
11
+ date: 2018-12-20 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
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.6'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.6'
55
55
  - !ruby/object:Gem::Dependency
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: '0.49'
69
69
  description: OmniAuth strategy for Mail.ru
70
70
  email:
71
- - andrey.skuryatin@gmai.com
71
+ - andrey.skuryatin@gmail.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -83,7 +83,6 @@ files:
83
83
  - lib/omniauth/mail_ru/version.rb
84
84
  - lib/omniauth/strategies/mail_ru.rb
85
85
  - omniauth-mail_ru.gemspec
86
- - spec/omniauth/strategies/mail_ru_spec.rb
87
86
  - spec/rubocop_spec.rb
88
87
  - spec/spec_helper.rb
89
88
  homepage: https://github.com/andrey-skat/omniauth-mail_ru
@@ -106,11 +105,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
105
  version: '0'
107
106
  requirements: []
108
107
  rubyforge_project:
109
- rubygems_version: 2.7.6
108
+ rubygems_version: 2.6.14.3
110
109
  signing_key:
111
110
  specification_version: 4
112
111
  summary: OmniAuth strategy for Mail.ru
113
112
  test_files:
114
- - spec/omniauth/strategies/mail_ru_spec.rb
115
113
  - spec/rubocop_spec.rb
116
114
  - spec/spec_helper.rb
@@ -1,99 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'omniauth-mail_ru'
5
-
6
- describe OmniAuth::Strategies::MailRu do
7
- let(:request) { double('Request', params: {}, cookies: {}, env: {}) }
8
- let(:app) do
9
- lambda do
10
- [200, {}, ['Hello.']]
11
- end
12
- end
13
-
14
- subject do
15
- OmniAuth::Strategies::MailRu.new(app, 'appid', 'secret', @options || {}).tap do |strategy|
16
- allow(strategy).to receive(:request) do
17
- request
18
- end
19
- end
20
- end
21
-
22
- before do
23
- OmniAuth.config.test_mode = true
24
- end
25
-
26
- after do
27
- OmniAuth.config.test_mode = false
28
- end
29
-
30
- describe '#client_options' do
31
- it 'has correct site' do
32
- expect(subject.client.site).to eq('https://connect.mail.ru')
33
- end
34
-
35
- it 'has correct authorize_url' do
36
- expect(subject.client.options[:authorize_url]).to eq('/oauth/authorize')
37
- end
38
-
39
- it 'has correct token_url' do
40
- expect(subject.client.options[:token_url]).to eq('/oauth/token')
41
- end
42
-
43
- describe 'overrides' do
44
- context 'as strings' do
45
- it 'should allow overriding the site' do
46
- @options = { client_options: { 'site' => 'https://example.com' } }
47
- expect(subject.client.site).to eq('https://example.com')
48
- end
49
-
50
- it 'should allow overriding the authorize_url' do
51
- @options = { client_options: { 'authorize_url' => 'https://example.com' } }
52
- expect(subject.client.options[:authorize_url]).to eq('https://example.com')
53
- end
54
-
55
- it 'should allow overriding the token_url' do
56
- @options = { client_options: { 'token_url' => 'https://example.com' } }
57
- expect(subject.client.options[:token_url]).to eq('https://example.com')
58
- end
59
- end
60
-
61
- context 'as symbols' do
62
- it 'should allow overriding the site' do
63
- @options = { client_options: { site: 'https://example.com' } }
64
- expect(subject.client.site).to eq('https://example.com')
65
- end
66
-
67
- it 'should allow overriding the authorize_url' do
68
- @options = { client_options: { authorize_url: 'https://example.com' } }
69
- expect(subject.client.options[:authorize_url]).to eq('https://example.com')
70
- end
71
-
72
- it 'should allow overriding the token_url' do
73
- @options = { client_options: { token_url: 'https://example.com' } }
74
- expect(subject.client.options[:token_url]).to eq('https://example.com')
75
- end
76
- end
77
- end
78
- end
79
-
80
- describe 'raw_info' do
81
- it 'should have pic_50 url' do
82
- allow(subject).to receive(:raw_info) { { 'has_pic' => '1', 'pic_50' => 'http://avt-17.foto.mail.ru/mail/test/_avatar50?111' } }
83
-
84
- expect(subject.info[:image]).to eq('http://avt-17.foto.mail.ru/mail/test/_avatar50?111')
85
- end
86
-
87
- it 'should have pic_small url' do
88
- allow(subject).to receive(:raw_info) { { 'has_pic' => '1', 'pic_small' => 'http://avt-17.foto.mail.ru/mail/test/_avatarsmall?111' } }
89
-
90
- expect(subject.info[:image]).to eq('http://avt-17.foto.mail.ru/mail/test/_avatarsmall?111')
91
- end
92
-
93
- it 'should not have pic url' do
94
- allow(subject).to receive(:raw_info) { { 'has_pic' => '0', 'pic_50' => 'http://avt-17.foto.mail.ru/mail/test/_avatar50?111', 'pic_small' => 'http://avt-17.foto.mail.ru/mail/test/_avatarsmall?111' } }
95
-
96
- expect(subject.info[:image]).to be_nil
97
- end
98
- end
99
- end