pax_global_header00006660000000000000000000000064124607634040014520gustar00rootroot0000000000000052 comment=b1063e7f6536f64a9b0c73e8c6468800e73bec01 omniauth-gitlab-1.0.0/000077500000000000000000000000001246076340400146025ustar00rootroot00000000000000omniauth-gitlab-1.0.0/.gitignore000066400000000000000000000002411246076340400165670ustar00rootroot00000000000000*.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-1.0.0/.project000066400000000000000000000006511246076340400162530ustar00rootroot00000000000000 omniauth-gitlab com.aptana.ide.core.unifiedBuilder com.aptana.ruby.core.rubynature com.aptana.projects.webnature omniauth-gitlab-1.0.0/.rspec000066400000000000000000000000111246076340400157070ustar00rootroot00000000000000--colour omniauth-gitlab-1.0.0/Gemfile000066400000000000000000000001441246076340400160740ustar00rootroot00000000000000source 'https://rubygems.org' # Specify your gem's dependencies in omniauth-gitlab.gemspec gemspec omniauth-gitlab-1.0.0/LICENSE.txt000066400000000000000000000020451246076340400164260ustar00rootroot00000000000000Copyright (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-1.0.0/README.md000066400000000000000000000021061246076340400160600ustar00rootroot00000000000000# Omniauth::Gitlab 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', authorize_url: '/oauth/authorize', token_url: '/oauth/token' } 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-1.0.0/Rakefile000066400000000000000000000001761246076340400162530ustar00rootroot00000000000000require "bundler/gem_tasks" require 'rspec/core/rake_task' RSpec::Core::RakeTask.new desc 'Run specs' task :default => :specomniauth-gitlab-1.0.0/lib/000077500000000000000000000000001246076340400153505ustar00rootroot00000000000000omniauth-gitlab-1.0.0/lib/omniauth-gitlab.rb000066400000000000000000000001071246076340400207570ustar00rootroot00000000000000require "omniauth-gitlab/version" require 'omniauth/strategies/gitlab' omniauth-gitlab-1.0.0/lib/omniauth-gitlab/000077500000000000000000000000001246076340400204345ustar00rootroot00000000000000omniauth-gitlab-1.0.0/lib/omniauth-gitlab/version.rb000066400000000000000000000001001246076340400224350ustar00rootroot00000000000000module Omniauth module Gitlab VERSION = "1.0.0" end end omniauth-gitlab-1.0.0/lib/omniauth/000077500000000000000000000000001246076340400171745ustar00rootroot00000000000000omniauth-gitlab-1.0.0/lib/omniauth/strategies/000077500000000000000000000000001246076340400213465ustar00rootroot00000000000000omniauth-gitlab-1.0.0/lib/omniauth/strategies/gitlab.rb000066400000000000000000000012711246076340400231360ustar00rootroot00000000000000 require 'omniauth-oauth2' module OmniAuth module Strategies class GitLab < OmniAuth::Strategies::OAuth2 option :client_options, { site: 'https://gitlab.com', authorize_url: '/oauth/authorize', token_url: '/oauth/token' } uid { raw_info['id'].to_s } info do { name: raw_info['name'], username: raw_info['username'], email: raw_info['email'] } end extra do { raw_info: raw_info } end def raw_info @raw_info ||= access_token.get('/api/v3/user').parsed end end end end OmniAuth.config.add_camelization 'gitlab', 'GitLab' omniauth-gitlab-1.0.0/omniauth-gitlab.gemspec000066400000000000000000000021261246076340400212340ustar00rootroot00000000000000# -*- 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 = ["ssein"] gem.email = ["ssein@undev.ru"] gem.description = %q{This is the strategy for authenticating to your GitLab service} gem.summary = %q{This is the strategy for authenticating to your GitLab service} gem.homepage = "" 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', '~> 1.0' gem.add_dependency 'omniauth-oauth2', '~> 1.0' gem.add_development_dependency 'rspec', '~> 3.1' gem.add_development_dependency 'rspec-its', '~> 1.0' gem.add_development_dependency 'rack-test' gem.add_development_dependency 'simplecov' gem.add_development_dependency 'webmock' end omniauth-gitlab-1.0.0/spec/000077500000000000000000000000001246076340400155345ustar00rootroot00000000000000omniauth-gitlab-1.0.0/spec/omniauth/000077500000000000000000000000001246076340400173605ustar00rootroot00000000000000omniauth-gitlab-1.0.0/spec/omniauth/strategies/000077500000000000000000000000001246076340400215325ustar00rootroot00000000000000omniauth-gitlab-1.0.0/spec/omniauth/strategies/gitlab_spec.rb000066400000000000000000000035421246076340400243370ustar00rootroot00000000000000require '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/api/v3' } let(:enterprise_authorize_url) { '/oauth/authorize' } let(:enterprise_token_url) { '/oauth/access_token' } let(:gitlab_service) { OmniAuth::Strategies::GitLab.new({}) } let(:enterprise) do OmniAuth::Strategies::GitLab.new('GITLAB_KEY', 'GITLAB_SECRET', client_options: { site: enterprise_site, authorize_url: enterprise_authorize_url, token_url: enterprise_token_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' } its(:authorize_url) { is_expected.to eq '/oauth/authorize' } its(:token_url) { is_expected.to eq '/oauth/token' } end context 'with override' do subject { enterprise.options.client_options } its(:site) { is_expected.to eq enterprise_site } its(:authorize_url) { is_expected.to eq enterprise_authorize_url } its(:token_url) { is_expected.to eq enterprise_token_url } end end describe '#raw_info' do it 'sent request to current user endpoint' do expect(access_token).to receive(:get).with('/api/v3/user').and_return(response) expect(subject.raw_info).to eq(parsed_response) end end end omniauth-gitlab-1.0.0/spec/spec_helper.rb000066400000000000000000000006521246076340400203550ustar00rootroot00000000000000$:.unshift File.expand_path('..', __FILE__) $:.unshift File.expand_path('../../lib', __FILE__) require 'simplecov' SimpleCov.start require 'rspec' require 'rspec/its' require 'rack/test' require 'webmock/rspec' require 'omniauth' require 'omniauth-gitlab' RSpec.configure do |config| config.include WebMock::API config.include Rack::Test::Methods config.extend OmniAuth::Test::StrategyMacros, :type => :strategy end