oauth2_dingtalk 0.2.0 → 0.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f094f2ae0851b8d3ef012277cd7b19604caa24f5
4
- data.tar.gz: 554102e2502536878ac3bbecd23ff668f5a41776
2
+ SHA256:
3
+ metadata.gz: 6f1a50b4c7adb4c65a2281255e965213362891edaa823d09ab2e030552a8a68a
4
+ data.tar.gz: e41fc8e7a6bece7a68b28d59c06e69c2678443c5053b483f694808cc87928182
5
5
  SHA512:
6
- metadata.gz: 0df169d104797d520f06e6174a2fe58545c5564daa02805c1564e77672e94868ab85eba446954707c0f339fe2554dc41bb47e204541dd6b5e68d276c792ee441
7
- data.tar.gz: a5dee3785d82e17a08228f202f53f28c7dc9382bbd1a1809e2a5f263e8b207c51a2719e0d6ff2a32813c276496c5d966d511541bc6a4e19e1ff67fd4af3c36fe
6
+ metadata.gz: b73082196754e98fee437498f1c0b0e78d94825c1d7185a68da4bf9aa3ccf1ab63b72cbcd795467ff7767d42b2b01f81875482c6f3f15ff7507251940d9ab512
7
+ data.tar.gz: 1ac1103b09ee4371b8baf5754eefd69e2955bd4878ef0f91f02046602f563f14c9e1b861a28c50a670ddef784335a5e0ccc30106dc89abd7840c1fd28a706d7a
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -12,3 +11,6 @@
12
11
  .rspec_status
13
12
  /example/.bundle/*
14
13
  /example/Gemfile.lock
14
+
15
+ # rbenv
16
+ .ruby-version
data/.rubocop.yml CHANGED
@@ -4,3 +4,5 @@ Documentation:
4
4
  Enabled: false
5
5
  Metrics/BlockLength:
6
6
  Enabled: false
7
+ Style/MultilineTernaryOperator:
8
+ Enabled: false
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ oauth2_dingtalk (0.2.2)
5
+ omniauth (~> 1.0)
6
+ omniauth-oauth2 (~> 1.0)
7
+ useragent
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.0)
13
+ diff-lcs (1.3)
14
+ faraday (0.12.2)
15
+ multipart-post (>= 1.2, < 3)
16
+ hashie (3.5.7)
17
+ jaro_winkler (1.5.1)
18
+ jwt (1.5.6)
19
+ multi_json (1.13.1)
20
+ multi_xml (0.6.0)
21
+ multipart-post (2.0.0)
22
+ oauth2 (1.4.0)
23
+ faraday (>= 0.8, < 0.13)
24
+ jwt (~> 1.0)
25
+ multi_json (~> 1.3)
26
+ multi_xml (~> 0.5)
27
+ rack (>= 1.2, < 3)
28
+ omniauth (1.8.1)
29
+ hashie (>= 3.4.6, < 3.6.0)
30
+ rack (>= 1.6.2, < 3)
31
+ omniauth-oauth2 (1.5.0)
32
+ oauth2 (~> 1.1)
33
+ omniauth (~> 1.2)
34
+ parallel (1.12.1)
35
+ parser (2.5.1.2)
36
+ ast (~> 2.4.0)
37
+ powerpack (0.1.2)
38
+ rack (2.0.5)
39
+ rainbow (3.0.0)
40
+ rake (10.5.0)
41
+ rspec (3.8.0)
42
+ rspec-core (~> 3.8.0)
43
+ rspec-expectations (~> 3.8.0)
44
+ rspec-mocks (~> 3.8.0)
45
+ rspec-core (3.8.0)
46
+ rspec-support (~> 3.8.0)
47
+ rspec-expectations (3.8.1)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.8.0)
50
+ rspec-mocks (3.8.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.8.0)
53
+ rspec-support (3.8.0)
54
+ rubocop (0.58.2)
55
+ jaro_winkler (~> 1.5.1)
56
+ parallel (~> 1.10)
57
+ parser (>= 2.5, != 2.5.1.1)
58
+ powerpack (~> 0.1)
59
+ rainbow (>= 2.2.2, < 4.0)
60
+ ruby-progressbar (~> 1.7)
61
+ unicode-display_width (~> 1.0, >= 1.0.1)
62
+ ruby-progressbar (1.10.0)
63
+ unicode-display_width (1.4.0)
64
+ useragent (0.16.10)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ bundler (~> 1.15)
71
+ oauth2_dingtalk!
72
+ rake (~> 10.0)
73
+ rspec (~> 3.0)
74
+ rubocop (~> 0.55)
75
+
76
+ BUNDLED WITH
77
+ 1.16.2
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/oauth2_dingtalk.svg)](https://badge.fury.io/rb/oauth2_dingtalk)
2
+ [![Build Status](https://travis-ci.org/liukun-lk/oauth2_dingtalk.svg?branch=master)](https://travis-ci.org/liukun-lk/oauth2_dingtalk)
2
3
 
3
4
  # Omniauth DingTalk Strategies
4
5
 
@@ -43,10 +44,6 @@ Here's an example of an authentication hash available in the callback by accessi
43
44
  ```ruby
44
45
  {
45
46
  "provider": "dingding",
46
- "uid": "uid",
47
- "info": {
48
- "name": "liukun",
49
- "ding_id": "ding_id"
50
- }
47
+ "uid": "uid" # this is openid in DingTalk
51
48
  }
52
49
  ```
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
3
4
 
5
+ RuboCop::RakeTask.new
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task default: :spec
8
+ task default: %i[rubocop spec]
data/example/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'multi_json'
4
- gem 'oauth2_dingtalk'
4
+ gem 'oauth2_dingtalk', path: '../omniauth-dingtalk'
5
5
  gem 'sinatra'
data/example/config.ru CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler'
2
2
  require 'sinatra'
3
- require 'oauth2_dingtalk'
3
+ require '../lib/oauth2_dingtalk'
4
4
 
5
5
  ENV['APPID'] = 'APPID'
6
6
  ENV['APPSECRET'] = 'APPSECRET'
@@ -1,3 +1,3 @@
1
1
  module Oauth2Dingtalk
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'omniauth-oauth2'
2
+ require 'useragent'
2
3
 
3
4
  module OmniAuth
4
5
  module Strategies
@@ -7,7 +8,9 @@ module OmniAuth
7
8
 
8
9
  option :client_options,
9
10
  site: 'https://oapi.dingtalk.com',
10
- authorize_url: '/connect/qrconnect',
11
+ authorize_url: '/:placeholder',
12
+ scan_code_authorize_url: '/connect/qrconnect',
13
+ account_authorize_url: '/connect/oauth2/sns_authorize',
11
14
  token_url: '/sns/gettoken',
12
15
  persistent_url: '/sns/get_persistent_code',
13
16
  sns_token: '/sns/get_sns_token',
@@ -17,11 +20,12 @@ module OmniAuth
17
20
  option :authorize_params, scope: 'snsapi_login'
18
21
 
19
22
  uid do
20
- raw_info['user_info']['unionid']
23
+ raw_info['user_info']['openid']
21
24
  end
22
25
 
23
26
  info do
24
27
  {
28
+ unionid: raw_info['user_info']['unionid'],
25
29
  name: raw_info['user_info']['nick'],
26
30
  ding_id: raw_info['user_info']['dingId']
27
31
  }
@@ -34,7 +38,7 @@ module OmniAuth
34
38
  def request_phase
35
39
  params = client.auth_code.authorize_params.merge(redirect_uri: callback_url).merge(authorize_params)
36
40
  params['appid'] = params.delete('client_id')
37
- redirect client.authorize_url(params)
41
+ redirect scan_code_or_account_verify(client.authorize_url(params))
38
42
  end
39
43
 
40
44
  def raw_info
@@ -74,6 +78,12 @@ module OmniAuth
74
78
  @user_info ||=
75
79
  access_token.get(options.client_options.user_info + "?sns_token=#{@sns_token['sns_token']}").parsed
76
80
  end
81
+
82
+ def scan_code_or_account_verify(url)
83
+ url.sub!('/:placeholder',
84
+ UserAgent.parse(request.env['HTTP_USER_AGENT']).mobile? ?
85
+ options.client_options.account_authorize_url : options.client_options.scan_code_authorize_url)
86
+ end
77
87
  end
78
88
  end
79
89
  end
@@ -1,5 +1,4 @@
1
-
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'oauth2_dingtalk/version'
5
4
 
@@ -23,8 +22,9 @@ Gem::Specification.new do |spec|
23
22
  spec.add_development_dependency 'bundler', '~> 1.15'
24
23
  spec.add_development_dependency 'rake', '~> 10.0'
25
24
  spec.add_development_dependency 'rspec', '~> 3.0'
26
- spec.add_development_dependency 'rubocop', '~> 0.52'
25
+ spec.add_development_dependency 'rubocop', '~> 0.55'
27
26
 
28
27
  spec.add_dependency 'omniauth', '~> 1.0'
29
28
  spec.add_dependency 'omniauth-oauth2', '~> 1.0'
29
+ spec.add_dependency 'useragent'
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth2_dingtalk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - liukun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-14 00:00:00.000000000 Z
11
+ date: 2018-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.52'
61
+ version: '0.55'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.52'
68
+ version: '0.55'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: omniauth
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: useragent
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Omniauth strategy for DingTalk(alibaba)
98
112
  email:
99
113
  - fee1mix@163.com
@@ -106,6 +120,7 @@ files:
106
120
  - ".rubocop.yml"
107
121
  - ".travis.yml"
108
122
  - Gemfile
123
+ - Gemfile.lock
109
124
  - LICENSE
110
125
  - README.md
111
126
  - Rakefile
@@ -137,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
152
  version: '0'
138
153
  requirements: []
139
154
  rubyforge_project:
140
- rubygems_version: 2.6.13
155
+ rubygems_version: 2.7.6
141
156
  signing_key:
142
157
  specification_version: 4
143
158
  summary: Omniauth strategy for DingTalk(alibaba)