omniauth-gitlab-1.0.2/0000755000004100000410000000000012726177505014642 5ustar www-datawww-dataomniauth-gitlab-1.0.2/Rakefile0000644000004100000410000000017612726177505016313 0ustar www-datawww-datarequire "bundler/gem_tasks" require 'rspec/core/rake_task' RSpec::Core::RakeTask.new desc 'Run specs' task :default => :specomniauth-gitlab-1.0.2/Gemfile0000644000004100000410000000014412726177505016134 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in omniauth-gitlab.gemspec gemspec omniauth-gitlab-1.0.2/.rspec0000644000004100000410000000001112726177505015747 0ustar www-datawww-data--colour omniauth-gitlab-1.0.2/.project0000644000004100000410000000065112726177505016313 0ustar www-datawww-data omniauth-gitlab com.aptana.ide.core.unifiedBuilder com.aptana.ruby.core.rubynature com.aptana.projects.webnature omniauth-gitlab-1.0.2/LICENSE.txt0000644000004100000410000000204512726177505016466 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-1.0.2/spec/0000755000004100000410000000000012726177505015574 5ustar www-datawww-dataomniauth-gitlab-1.0.2/spec/omniauth/0000755000004100000410000000000012726177505017420 5ustar www-datawww-dataomniauth-gitlab-1.0.2/spec/omniauth/strategies/0000755000004100000410000000000012726177505021572 5ustar www-datawww-dataomniauth-gitlab-1.0.2/spec/omniauth/strategies/gitlab_spec.rb0000644000004100000410000000440612726177505024377 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/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 }, 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' } 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 '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/v3/user').and_return(response) expect(subject.raw_info).to eq(parsed_response) end end end omniauth-gitlab-1.0.2/spec/spec_helper.rb0000644000004100000410000000065212726177505020415 0ustar www-datawww-data$:.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 omniauth-gitlab-1.0.2/lib/0000755000004100000410000000000012726177505015410 5ustar www-datawww-dataomniauth-gitlab-1.0.2/lib/omniauth-gitlab/0000755000004100000410000000000012726177505020474 5ustar www-datawww-dataomniauth-gitlab-1.0.2/lib/omniauth-gitlab/version.rb0000644000004100000410000000010012726177505022475 0ustar www-datawww-datamodule Omniauth module Gitlab VERSION = '1.0.2' end end omniauth-gitlab-1.0.2/lib/omniauth/0000755000004100000410000000000012726177505017234 5ustar www-datawww-dataomniauth-gitlab-1.0.2/lib/omniauth/strategies/0000755000004100000410000000000012726177505021406 5ustar www-datawww-dataomniauth-gitlab-1.0.2/lib/omniauth/strategies/gitlab.rb0000644000004100000410000000157612726177505023206 0ustar www-datawww-data 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' } 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/v3/user').parsed end private def callback_url options.redirect_url || (full_host + script_name + callback_path) end end end end OmniAuth.config.add_camelization 'gitlab', 'GitLab' omniauth-gitlab-1.0.2/lib/omniauth-gitlab.rb0000644000004100000410000000010712726177505021017 0ustar www-datawww-datarequire "omniauth-gitlab/version" require 'omniauth/strategies/gitlab' omniauth-gitlab-1.0.2/.gitignore0000644000004100000410000000024112726177505016627 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-1.0.2/README.md0000644000004100000410000000244612726177505016127 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', 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.2/omniauth-gitlab.gemspec0000644000004100000410000000220312726177505021270 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 = ['ssein'] gem.email = ['linchus@gmail.com'] 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 = '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', '~> 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