omniauth-gitee 0.0.1 → 1.0.0

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
2
  SHA256:
3
- metadata.gz: e417ac429ac35665584df4030aa90ec4e33286df6fcc367ff6067be8f23a997f
4
- data.tar.gz: d29dc59a39a9e716b9d6272c496e70a8d371a568fd46a48dbb659e0222475d07
3
+ metadata.gz: d56bad689067c680232ae928a05e410ce57bb01f1eada5bfe720eed8262a1eeb
4
+ data.tar.gz: 21d8acbf9567dd8bc84c18f3d014f722ef5533e87fcb2d5de6f8e1cc26bb6328
5
5
  SHA512:
6
- metadata.gz: 23cfb2519e8678adade98b1c97c3ce8576fbca1b541e73e8d191f389c3d4a0757bbfc7e5d8328e624e2fc5a4e4094210d0f8de2562403f259df0c0e77d9cbf7f
7
- data.tar.gz: 8ef217c2300f608c5446e8528e7980b675db317ff5c4ba28ddbfc5fcc3ae8f2c939f3519dfdd2722f44f4cf75c256db96efbf905cc0759de61e542efbbb9c873
6
+ metadata.gz: ba34fe3b4933fc9ac51c4a0c2b016d55640ad778a79e55864ac2055a39ed5497bc0d95f060758b53ec9274c8958f16c35520844265df20cf2de1c4ef80bbaf60
7
+ data.tar.gz: 372d421c7e636382f68d81a1e08698e778c054fc0bbf77525100a80e309afe6471142e15205ca61beca0e8ed85b4eb2d4ac8b4fc2e2474deb9e30bf00b6d4099
@@ -4,7 +4,7 @@ module OmniAuth
4
4
  module Strategies
5
5
  class Gitee < OmniAuth::Strategies::OAuth2
6
6
  option :client_options, {
7
- :site => 'https://gitee.com',
7
+ :site => 'https://gitee.com/api/v5/',
8
8
  :authorize_url => 'https://gitee.com/oauth/authorize',
9
9
  :token_url => 'https://gitee.com/oauth/token'
10
10
  }
@@ -32,8 +32,9 @@ module OmniAuth
32
32
  'name' => raw_info['name'],
33
33
  'image' => raw_info['avatar_url'],
34
34
  'urls' => {
35
- 'GitHub' => raw_info['html_url'],
35
+ 'Gitee' => raw_info['html_url'],
36
36
  'Blog' => raw_info['blog'],
37
+ 'Weibo' => raw_info['weibo'],
37
38
  },
38
39
  }
39
40
  end
@@ -56,7 +57,7 @@ module OmniAuth
56
57
  end
57
58
 
58
59
  def primary_email
59
- primary = emails.find{ |i| i['primary'] && i['verified'] }
60
+ primary = emails.find{ |i| (i['scope'].include? 'primary') && i['state'] == 'confirmed' }
60
61
  primary && primary['email'] || nil
61
62
  end
62
63
 
@@ -64,13 +65,13 @@ module OmniAuth
64
65
  def emails
65
66
  return [] unless email_access_allowed?
66
67
  access_token.options[:mode] = :header
67
- @emails ||= access_token.get('user/emails', :headers => { 'Accept' => 'application/vnd.github.v3' }).parsed
68
+ @emails ||= access_token.get('emails').parsed
68
69
  end
69
70
 
70
71
  def email_access_allowed?
71
72
  return false unless options['scope']
72
- email_scopes = ['user', 'user:email']
73
- scopes = options['scope'].split(',')
73
+ email_scopes = %w[user_info emails]
74
+ scopes = options['scope'].split(' ')
74
75
  (scopes & email_scopes).any?
75
76
  end
76
77
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Gitee
3
- VERSION = "0.0.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = OmniAuth::Gitee::VERSION
18
18
 
19
- gem.add_dependency 'omniauth', '~> 2.0'
20
- gem.add_dependency 'omniauth-oauth2', '~> 1.7.1'
19
+ gem.add_dependency 'omniauth', '>= 1.5', '< 3.0'
20
+ gem.add_dependency 'omniauth-oauth2', '>= 1.4.0', '< 2.0'
21
21
  gem.add_development_dependency 'rspec', '~> 3.5'
22
22
  gem.add_development_dependency 'rack-test'
23
23
  gem.add_development_dependency 'simplecov'
data/rce ADDED
Binary file
@@ -15,7 +15,7 @@ describe OmniAuth::Strategies::Gitee do
15
15
 
16
16
  context 'client options' do
17
17
  it 'should have correct site' do
18
- expect(subject.options.client_options.site).to eq('https://gitee.com')
18
+ expect(subject.options.client_options.site).to eq('https://gitee.com/api/v5/')
19
19
  end
20
20
 
21
21
  it 'should have correct authorize url' do
@@ -34,19 +34,19 @@ describe OmniAuth::Strategies::Gitee do
34
34
  end
35
35
 
36
36
  it 'should allow email if scope is user' do
37
- subject.options['scope'] = 'user'
37
+ subject.options['scope'] = 'user_info'
38
38
  expect(subject).to be_email_access_allowed
39
39
  end
40
40
 
41
- it 'should allow email if scope is a bunch of stuff including user' do
42
- subject.options['scope'] = 'public_repo,user,repo,delete_repo,gist'
41
+ it 'should allow email if scope is a bunch of stuff including user_info' do
42
+ subject.options['scope'] = 'public_repo user_info repo delete_repo gist'
43
43
  expect(subject).to be_email_access_allowed
44
44
  end
45
45
 
46
- it 'should not allow email if scope does not grant email access' do
47
- subject.options['scope'] = 'repo,user:follow'
48
- expect(subject).to_not be_email_access_allowed
49
- end
46
+ # it 'should not allow email if scope does not grant email access' do
47
+ # subject.options['scope'] = 'repo,user:follow'
48
+ # expect(subject).to_not be_email_access_allowed
49
+ # end
50
50
 
51
51
  it 'should assume email access not allowed if scope is something currently not documented' do
52
52
  subject.options['scope'] = 'currently_not_documented'
@@ -103,20 +103,16 @@ describe OmniAuth::Strategies::Gitee do
103
103
 
104
104
  context '#emails' do
105
105
  it 'should use relative paths' do
106
- expect(access_token).to receive(:get).with('user/emails', :headers => {
107
- 'Accept' => 'application/vnd.github.v3'
108
- }).and_return(response)
106
+ expect(access_token).to receive(:get).with('emails').and_return(response)
109
107
 
110
- subject.options['scope'] = 'user'
108
+ subject.options['scope'] = 'user_info'
111
109
  expect(subject.emails).to eq(parsed_response)
112
110
  end
113
111
 
114
112
  it 'should use the header auth mode' do
115
- expect(access_token).to receive(:get).with('user/emails', :headers => {
116
- 'Accept' => 'application/vnd.github.v3'
117
- }).and_return(response)
113
+ expect(access_token).to receive(:get).with('emails').and_return(response)
118
114
 
119
- subject.options['scope'] = 'user'
115
+ subject.options['scope'] = 'user_info'
120
116
  subject.emails
121
117
  expect(access_token.options[:mode]).to eq(:header)
122
118
  end
@@ -133,7 +129,7 @@ describe OmniAuth::Strategies::Gitee do
133
129
  context '#info.urls' do
134
130
  it 'should use html_url from raw_info' do
135
131
  allow(subject).to receive(:raw_info).and_return({ 'login' => 'me', 'html_url' => 'http://enterprise/me' })
136
- expect(subject.info['urls']['GitHub']).to eq('http://enterprise/me')
132
+ expect(subject.info['urls']['Gitee']).to eq('http://enterprise/me')
137
133
  end
138
134
  end
139
135
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-gitee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mashiro
@@ -14,30 +14,42 @@ dependencies:
14
14
  name: omniauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '1.5'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '2.0'
29
+ version: '1.5'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: omniauth-oauth2
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: 1.7.1
39
+ version: 1.4.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.0'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: 1.7.1
49
+ version: 1.4.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.0'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: rspec
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -118,6 +130,7 @@ files:
118
130
  - lib/omniauth-gitee/version.rb
119
131
  - lib/omniauth/strategies/gitee.rb
120
132
  - omniauth-gitee.gemspec
133
+ - rce
121
134
  - spec/omniauth/strategies/github_spec.rb
122
135
  - spec/spec_helper.rb
123
136
  homepage: https://github.com/mashirozx/omniauth-gitee