omniauth-gitlab 1.0.1 → 3.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
- SHA1:
3
- metadata.gz: 24e5db0951198ccfb5473ff5fe3a6a626b91edfe
4
- data.tar.gz: cb7f0598640a8c6a80245cbb6f5758e53670eef3
2
+ SHA256:
3
+ metadata.gz: 9f47d5dde46b9dc356bd1ec717ba0b7dc87b49e188b84dcf1617d366709f390f
4
+ data.tar.gz: 6661be3cca493f7891e4663fead785e36639e121c4dde78b7b61de281dd3b08d
5
5
  SHA512:
6
- metadata.gz: 2fe15159ccfe5f31ff1266b036aa3b4366623f1c669a69599fa710ac77679093377135aa75d77b8b4446a8dbfcf8635cf1ed7de8e30b561712a45354072bcc44
7
- data.tar.gz: 9611dc576bdba0613f62c452bdd4583d5c584c428395062bd732ffe9ea1833a401623daa15c444420f8a9f757391b58a2546ec7da3ba6cce473bb6e7442a07a5
6
+ metadata.gz: 8c25c70c310391102a0c594ab09b1122e2ca4d8d761a631a7460e04ecce9120bdaa17bc29c3cd40cfbc17b62936c85973c8a10e63d1f6c37d6bbc268175ef33f
7
+ data.tar.gz: 91165b4ffb9b274608f91a131c4514611536626384ed7ddcfe356bf4b0049bc8b4fb143b6cc159d974d1657a1e5f084d32b4985d215727c15d7d6f45ec12b449
data/README.md CHANGED
@@ -31,12 +31,39 @@ Or install it yourself as:
31
31
  ## Standalone Usage
32
32
 
33
33
  use OmniAuth::Builder do
34
- provider :gitlab, ENV['GITLAB_KEY'], ENV['GITLAB_SECRET'],
35
- client_options: {
36
- site: 'https://gitlab.YOURDOMAIN.com',
37
- authorize_url: '/oauth/authorize',
38
- token_url: '/oauth/token'
39
- }
34
+ provider :gitlab, ENV['GITLAB_KEY'], ENV['GITLAB_SECRET'],
35
+ {
36
+ client_options: {
37
+ site: 'https://gitlab.YOURDOMAIN.com/api/v4'
38
+ }
39
+ }
40
+ end
41
+
42
+ ## Custom scopes
43
+
44
+ By default, the `api` scope is requested and must be allowed in GitLab's application configuration. To use different scopes:
45
+
46
+ use OmniAuth::Builder do
47
+ provider :gitlab, ENV['GITLAB_KEY'], ENV['GITLAB_SECRET'], scope: 'read_user openid'
48
+ end
49
+
50
+ Requesting a scope that is not configured will result the error "The requested scope is invalid, unknown, or malformed.".
51
+
52
+ ## Old API version
53
+
54
+ API V3 will be unsupported from GitLab 9.5 and will be removed in GitLab 9.5 or later.
55
+
56
+ [https://gitlab.com/help/api/v3_to_v4.md](https://gitlab.com/help/api/v3_to_v4.md)
57
+
58
+ If you use GitLab 9.0 and below you could configure V3 API:
59
+
60
+ use OmniAuth::Builder do
61
+ provider :gitlab, ENV['GITLAB_KEY'], ENV['GITLAB_SECRET'],
62
+ {
63
+ client_options: {
64
+ site: 'https://gitlab.YOURDOMAIN.com/api/v3'
65
+ }
66
+ }
40
67
  end
41
68
 
42
69
  ## Contributing
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new
5
5
 
6
6
  desc 'Run specs'
7
- task :default => :spec
7
+ task default: :spec
@@ -1,2 +1,2 @@
1
- require "omniauth-gitlab/version"
1
+ require 'omniauth-gitlab/version'
2
2
  require 'omniauth/strategies/gitlab'
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Gitlab
3
- VERSION = '1.0.1'
3
+ VERSION = '3.0.0'
4
4
  end
5
5
  end
@@ -4,21 +4,18 @@ require 'omniauth-oauth2'
4
4
  module OmniAuth
5
5
  module Strategies
6
6
  class GitLab < OmniAuth::Strategies::OAuth2
7
+ option :client_options, site: 'https://gitlab.com/api/v4'
7
8
 
8
- option :client_options, {
9
- site: 'https://gitlab.com',
10
- authorize_url: '/oauth/authorize',
11
- token_url: '/oauth/token'
12
- }
9
+ option :redirect_url
13
10
 
14
11
  uid { raw_info['id'].to_s }
15
12
 
16
13
  info do
17
14
  {
18
- name: raw_info['name'],
19
- username: raw_info['username'],
20
- email: raw_info['email'],
21
- image: raw_info['avatar_url']
15
+ name: raw_info['name'],
16
+ username: raw_info['username'],
17
+ email: raw_info['email'],
18
+ image: raw_info['avatar_url']
22
19
  }
23
20
  end
24
21
 
@@ -27,11 +24,16 @@ module OmniAuth
27
24
  end
28
25
 
29
26
  def raw_info
30
- @raw_info ||= access_token.get('/api/v3/user').parsed
27
+ @raw_info ||= access_token.get('user').parsed
28
+ end
29
+
30
+ private
31
+
32
+ def callback_url
33
+ options.redirect_url || (full_host + script_name + callback_path)
31
34
  end
32
35
  end
33
36
  end
34
37
  end
35
38
 
36
-
37
39
  OmniAuth.config.add_camelization 'gitlab', 'GitLab'
@@ -6,22 +6,21 @@ require 'omniauth-gitlab/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = 'omniauth-gitlab'
8
8
  gem.version = Omniauth::Gitlab::VERSION
9
- gem.authors = ['ssein']
9
+ gem.authors = ['Sergey Sein']
10
10
  gem.email = ['linchus@gmail.com']
11
- gem.description = %q{This is the strategy for authenticating to your GitLab service}
12
- gem.summary = %q{This is the strategy for authenticating to your GitLab service}
11
+ gem.description = 'This is the strategy for authenticating to your GitLab service'
12
+ gem.summary = 'This is the strategy for authenticating to your GitLab service'
13
13
  gem.homepage = 'https://github.com/linchus/omniauth-gitlab'
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
19
 
20
- gem.add_dependency 'omniauth', '~> 1.0'
21
- gem.add_dependency 'omniauth-oauth2', '~> 1.0'
20
+ gem.add_dependency 'omniauth', '~> 2.0'
21
+ gem.add_dependency 'omniauth-oauth2', '~> 1.7.1'
22
22
  gem.add_development_dependency 'rspec', '~> 3.1'
23
23
  gem.add_development_dependency 'rspec-its', '~> 1.0'
24
- gem.add_development_dependency 'rack-test'
25
24
  gem.add_development_dependency 'simplecov'
26
- gem.add_development_dependency 'webmock'
25
+ gem.add_development_dependency 'rake', '>= 12.0'
27
26
  end
@@ -1,23 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::GitLab do
4
-
5
4
  let(:access_token) { double('AccessToken') }
6
5
  let(:parsed_response) { double('ParsedResponse') }
7
6
  let(:response) { double('Response', parsed: parsed_response) }
8
7
 
9
- let(:enterprise_site) { 'https://some.other.site.com/api/v3' }
10
- let(:enterprise_authorize_url) { '/oauth/authorize' }
11
- let(:enterprise_token_url) { '/oauth/access_token' }
8
+ let(:enterprise_site) { 'https://some.other.site.com/api/v3' }
12
9
 
13
10
  let(:gitlab_service) { OmniAuth::Strategies::GitLab.new({}) }
14
11
  let(:enterprise) do
15
- OmniAuth::Strategies::GitLab.new('GITLAB_KEY', 'GITLAB_SECRET',
16
- client_options: {
17
- site: enterprise_site,
18
- authorize_url: enterprise_authorize_url,
19
- token_url: enterprise_token_url
20
- }
12
+ OmniAuth::Strategies::GitLab.new(
13
+ 'GITLAB_KEY',
14
+ 'GITLAB_SECRET',
15
+ client_options: { site: enterprise_site },
16
+ redirect_url: 'http://localhost:9292/callback_url'
21
17
  )
22
18
  end
23
19
 
@@ -31,23 +27,31 @@ describe OmniAuth::Strategies::GitLab do
31
27
  context 'with defaults' do
32
28
  subject { gitlab_service.options.client_options }
33
29
 
34
- its(:site) { is_expected.to eq 'https://gitlab.com' }
35
- its(:authorize_url) { is_expected.to eq '/oauth/authorize' }
36
- its(:token_url) { is_expected.to eq '/oauth/token' }
30
+ its(:site) { is_expected.to eq 'https://gitlab.com/api/v4' }
37
31
  end
38
32
 
39
33
  context 'with override' do
40
34
  subject { enterprise.options.client_options }
41
35
 
42
36
  its(:site) { is_expected.to eq enterprise_site }
43
- its(:authorize_url) { is_expected.to eq enterprise_authorize_url }
44
- its(:token_url) { is_expected.to eq enterprise_token_url }
37
+ end
38
+ end
39
+
40
+ describe 'redirect_url' do
41
+ context 'with defaults' do
42
+ subject { gitlab_service.options }
43
+ its(:redirect_url) { is_expected.to be_nil }
44
+ end
45
+
46
+ context 'with customs' do
47
+ subject { enterprise.options }
48
+ its(:redirect_url) { is_expected.to eq 'http://localhost:9292/callback_url' }
45
49
  end
46
50
  end
47
51
 
48
52
  describe '#raw_info' do
49
53
  it 'sent request to current user endpoint' do
50
- expect(access_token).to receive(:get).with('/api/v3/user').and_return(response)
54
+ expect(access_token).to receive(:get).with('user').and_return(response)
51
55
  expect(subject.raw_info).to eq(parsed_response)
52
56
  end
53
57
  end
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,8 @@
1
- $:.unshift File.expand_path('..', __FILE__)
2
- $:.unshift File.expand_path('../../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
3
  require 'simplecov'
4
4
  SimpleCov.start
5
5
  require 'rspec'
6
6
  require 'rspec/its'
7
- require 'rack/test'
8
- require 'webmock/rspec'
9
7
  require 'omniauth'
10
8
  require 'omniauth-gitlab'
11
-
12
- RSpec.configure do |config|
13
- config.include WebMock::API
14
- config.include Rack::Test::Methods
15
- config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
16
- end
17
-
18
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - ssein
7
+ - Sergey Sein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.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
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth-oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: 1.7.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: 1.7.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rack-test
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: simplecov
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -95,19 +81,19 @@ dependencies:
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
- name: webmock
84
+ name: rake
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
89
+ version: '12.0'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: '12.0'
111
97
  description: This is the strategy for authenticating to your GitLab service
112
98
  email:
113
99
  - linchus@gmail.com
@@ -146,12 +132,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
132
  - !ruby/object:Gem::Version
147
133
  version: '0'
148
134
  requirements: []
149
- rubyforge_project:
150
- rubygems_version: 2.2.2
135
+ rubygems_version: 3.0.3
151
136
  signing_key:
152
137
  specification_version: 4
153
138
  summary: This is the strategy for authenticating to your GitLab service
154
139
  test_files:
155
140
  - spec/omniauth/strategies/gitlab_spec.rb
156
141
  - spec/spec_helper.rb
157
- has_rdoc: