omniauth-gitlab-4.1.0/0000755000004100000410000000000014332064645014637 5ustar www-datawww-dataomniauth-gitlab-4.1.0/.rspec0000644000004100000410000000001114332064645015744 0ustar www-datawww-data--colour omniauth-gitlab-4.1.0/README.md0000644000004100000410000000372014332064645016120 0ustar www-datawww-data# Omniauth::Gitlab [![Join the chat at https://gitter.im/linchus/omniauth-gitlab](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/linchus/omniauth-gitlab?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) This is the OAuth2 strategy for authenticating to your GitLab service. ## Requirements Gitlab 7.7.0+ ## Installation Add this line to your application's Gemfile: gem 'omniauth-gitlab' And then execute: $ bundle Or install it yourself as: $ gem install omniauth-gitlab ## Basic Usage use OmniAuth::Builder do provider :gitlab, ENV['GITLAB_KEY'], ENV['GITLAB_SECRET'] end ## Standalone Usage use OmniAuth::Builder do provider :gitlab, ENV['GITLAB_KEY'], ENV['GITLAB_SECRET'], { client_options: { site: 'https://gitlab.YOURDOMAIN.com' } } end ## Custom scopes By default, the `api` scope is requested and must be allowed in GitLab's application configuration. To use different scopes: use OmniAuth::Builder do provider :gitlab, ENV['GITLAB_KEY'], ENV['GITLAB_SECRET'], scope: 'read_user openid' end Requesting a scope that is not configured will result the error "The requested scope is invalid, unknown, or malformed.". ## Old API version API V3 will be unsupported from GitLab 9.5 and will be removed in GitLab 9.5 or later. [https://gitlab.com/help/api/v3_to_v4.md](https://gitlab.com/help/api/v3_to_v4.md) If you use GitLab 9.0 and below you could configure V3 API: use OmniAuth::Builder do provider :gitlab, ENV['GITLAB_KEY'], ENV['GITLAB_SECRET'], { client_options: { site: 'https://gitlab.YOURDOMAIN.com/api/v3' } } end ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request omniauth-gitlab-4.1.0/spec/0000755000004100000410000000000014332064645015571 5ustar www-datawww-dataomniauth-gitlab-4.1.0/spec/omniauth/0000755000004100000410000000000014332064645017415 5ustar www-datawww-dataomniauth-gitlab-4.1.0/spec/omniauth/strategies/0000755000004100000410000000000014332064645021567 5ustar www-datawww-dataomniauth-gitlab-4.1.0/spec/omniauth/strategies/gitlab_spec.rb0000644000004100000410000000455014332064645024374 0ustar www-datawww-datarequire 'spec_helper' describe OmniAuth::Strategies::GitLab do let(:access_token) { double('AccessToken') } let(:parsed_response) { double('ParsedResponse') } let(:response) { double('Response', parsed: parsed_response) } let(:enterprise_site) { 'https://some.other.site.com' } let(:gitlab_service) { OmniAuth::Strategies::GitLab.new({}) } let(:enterprise) do OmniAuth::Strategies::GitLab.new( 'GITLAB_KEY', 'GITLAB_SECRET', client_options: { site: enterprise_site }, redirect_url: 'http://localhost:9292/callback_url' ) end subject { gitlab_service } before(:each) do allow(subject).to receive(:access_token).and_return(access_token) end describe 'client options' do context 'with defaults' do subject { gitlab_service.options.client_options } its(:site) { is_expected.to eq 'https://gitlab.com' } end context 'with override' do subject { enterprise.options.client_options } its(:site) { is_expected.to eq enterprise_site } end end describe 'redirect_url' do context 'with defaults' do subject { gitlab_service.options } its(:redirect_url) { is_expected.to be_nil } end context 'with customs' do subject { enterprise.options } its(:redirect_url) { is_expected.to eq 'http://localhost:9292/callback_url' } end end describe '#raw_info' do it 'sent request to current user endpoint' do expect(access_token).to receive(:get).with('api/v4/user').and_return(response) expect(subject.raw_info).to eq(parsed_response) end end describe '#callback_url' do let(:base_url) { 'https://example.com' } context 'no script name present' do it 'has the correct default callback path' do allow(subject).to receive(:full_host) { base_url } allow(subject).to receive(:script_name) { '' } allow(subject).to receive(:query_string) { '' } expect(subject.callback_url).to eq(base_url + '/auth/gitlab/callback') end end context 'script name' do it 'should set the callback path with script_name' do allow(subject).to receive(:full_host) { base_url } allow(subject).to receive(:script_name) { '/v1' } allow(subject).to receive(:query_string) { '' } expect(subject.callback_url).to eq(base_url + '/v1/auth/gitlab/callback') end end end end omniauth-gitlab-4.1.0/spec/spec_helper.rb0000644000004100000410000000034414332064645020410 0ustar www-datawww-data$LOAD_PATH.unshift File.expand_path('..', __FILE__) $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'simplecov' SimpleCov.start require 'rspec' require 'rspec/its' require 'omniauth' require 'omniauth-gitlab' omniauth-gitlab-4.1.0/.gitignore0000644000004100000410000000024114332064645016624 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc .rvmrc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp omniauth-gitlab-4.1.0/Rakefile0000644000004100000410000000017414332064645016306 0ustar www-datawww-datarequire 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new desc 'Run specs' task default: :spec omniauth-gitlab-4.1.0/lib/0000755000004100000410000000000014332064645015405 5ustar www-datawww-dataomniauth-gitlab-4.1.0/lib/omniauth/0000755000004100000410000000000014332064645017231 5ustar www-datawww-dataomniauth-gitlab-4.1.0/lib/omniauth/strategies/0000755000004100000410000000000014332064645021403 5ustar www-datawww-dataomniauth-gitlab-4.1.0/lib/omniauth/strategies/gitlab.rb0000644000004100000410000000134614332064645023176 0ustar www-datawww-data require 'omniauth-oauth2' module OmniAuth module Strategies class GitLab < OmniAuth::Strategies::OAuth2 option :client_options, site: 'https://gitlab.com' option :redirect_url uid { raw_info['id'].to_s } info do { name: raw_info['name'], username: raw_info['username'], email: raw_info['email'], image: raw_info['avatar_url'] } end extra do { raw_info: raw_info } end def raw_info @raw_info ||= access_token.get('api/v4/user').parsed end def callback_url options.redirect_url || (full_host + callback_path) end end end end OmniAuth.config.add_camelization 'gitlab', 'GitLab' omniauth-gitlab-4.1.0/lib/omniauth-gitlab.rb0000644000004100000410000000010714332064645021014 0ustar www-datawww-datarequire 'omniauth-gitlab/version' require 'omniauth/strategies/gitlab' omniauth-gitlab-4.1.0/lib/omniauth-gitlab/0000755000004100000410000000000014332064645020471 5ustar www-datawww-dataomniauth-gitlab-4.1.0/lib/omniauth-gitlab/version.rb0000644000004100000410000000010014332064645022472 0ustar www-datawww-datamodule Omniauth module Gitlab VERSION = '4.1.0' end end omniauth-gitlab-4.1.0/Gemfile0000644000004100000410000000014414332064645016131 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in omniauth-gitlab.gemspec gemspec omniauth-gitlab-4.1.0/.project0000644000004100000410000000065114332064645016310 0ustar www-datawww-data omniauth-gitlab com.aptana.ide.core.unifiedBuilder com.aptana.ruby.core.rubynature com.aptana.projects.webnature omniauth-gitlab-4.1.0/.github/0000755000004100000410000000000014332064645016177 5ustar www-datawww-dataomniauth-gitlab-4.1.0/.github/workflows/0000755000004100000410000000000014332064645020234 5ustar www-datawww-dataomniauth-gitlab-4.1.0/.github/workflows/ruby.yml0000644000004100000410000000071714332064645021745 0ustar www-datawww-dataname: CI on: [push, pull_request] jobs: test: runs-on: ubuntu-latest strategy: matrix: ruby-version: ['2.6', '2.7', '3.0', '3.1'] steps: - uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby-version }} uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # 'bundle install' and cache - name: Run specs run: | bundle exec rspec omniauth-gitlab-4.1.0/LICENSE.txt0000644000004100000410000000204514332064645016463 0ustar www-datawww-dataCopyright (c) 2013 ssein MIT License 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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.omniauth-gitlab-4.1.0/omniauth-gitlab.gemspec0000644000004100000410000000214314332064645021270 0ustar www-datawww-data# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'omniauth-gitlab/version' Gem::Specification.new do |gem| gem.name = 'omniauth-gitlab' gem.version = Omniauth::Gitlab::VERSION gem.authors = ['Sergey Sein'] gem.email = ['linchus@gmail.com'] gem.description = 'This is the strategy for authenticating to your GitLab service' gem.summary = 'This is the strategy for authenticating to your GitLab service' gem.homepage = 'https://github.com/linchus/omniauth-gitlab' gem.files = `git ls-files`.split($/) gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ['lib'] gem.add_dependency 'omniauth', '~> 2.0' gem.add_dependency 'omniauth-oauth2', '~> 1.8.0' gem.add_development_dependency 'rspec', '~> 3.1' gem.add_development_dependency 'rspec-its', '~> 1.0' gem.add_development_dependency 'simplecov' gem.add_development_dependency 'rake', '>= 12.0' end