omniauth-bitbucket2 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 42bfcbd38d09b6e78547be504e7426952f822680
4
+ data.tar.gz: 9a5c6568e77a96108defccd73d2118940567cbb7
5
+ SHA512:
6
+ metadata.gz: c8bdab6a24512ee74535ac33b2f690b0d8d8043bd2c4851876532074bef6ec44ecf4b2dbd0ccfd08568aca8ea066e60c96f8425fabae46c687a6d4265f58f741
7
+ data.tar.gz: c3bf0b1d21d54851bf5c3aca47ac0ef4486c6a5fcfaeb0f22efc56eb652ff0759cc2b88e7dfca2d015ff6b6eed232d9d5cc4027a9b1156599c68f769a192b56a
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ /pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-bitbucket2.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'rb-fsevent'
11
+ gem 'growl'
12
+ end
@@ -0,0 +1,10 @@
1
+ guard 'rspec', cmd: 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch('omniauth-bitbucket2.gemspec')
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Barnabas Birmacher
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
@@ -0,0 +1,55 @@
1
+ # OmniAuth Bitbucket2
2
+
3
+ This is the OmniAuth strategy for authenticating to [Bitbucket](https://bitbucket.org).
4
+ To use it, you'll need to signup for an OAuth2 Application ID and Secret on the Bitbucket Application Page.
5
+
6
+ ## Install
7
+
8
+ Add dependency to your Gemfile:
9
+
10
+ ```
11
+ gem 'omniauth-bitbucket2'
12
+ ```
13
+
14
+ Or install manually:
15
+
16
+ ```
17
+ gem install omniauth-bitbucket2
18
+ ```
19
+
20
+ ## Basic Usage
21
+
22
+ ```ruby
23
+ use OmniAuth::Builder do
24
+ provider :bitbucket, ENV['BITBUCKET_KEY'], ENV['BITBUCKET_SECRET']
25
+ end
26
+ ```
27
+
28
+ If using Rails, add an initializer `config/initializers/omniauth.rb`:
29
+
30
+ ```ruby
31
+ Rails.application.config.middleware.use OmniAuth::Builder do
32
+ provider :bitbuckett, 'BITBUCKET_KEY', 'BITBUCKET_SECRET'
33
+ end
34
+ ```
35
+
36
+ ## License
37
+
38
+ Copyright (c) 2015 Barnabas Birmacher.
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
41
+ this software and associated documentation files (the "Software"), to deal in
42
+ the Software without restriction, including without limitation the rights to
43
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
44
+ the Software, and to permit persons to whom the Software is furnished to do so,
45
+ subject to the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be included in all
48
+ copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
52
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
53
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
54
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
55
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require "omniauth-bitbucket2/version"
2
+ require 'omniauth/strategies/bitbucket2'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Bitbucket2
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,56 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Bitbucket2 < OmniAuth::Strategies::OAuth2
6
+ option :name, 'bitbucket'
7
+
8
+ option :client_options, {
9
+ :site => 'https://api.bitbucket.org/2.0',
10
+ :authorize_url => 'https://bitbucket.org/site/oauth2/authorize',
11
+ :token_url => 'https://bitbucket.org/site/oauth2/access_token'
12
+ }
13
+
14
+ def authorize_params
15
+ super.tap do |params|
16
+ %w[client_options].each do |v|
17
+ if request.params[v]
18
+ params[v.to_sym] = request.params[v]
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ uid { raw_info['uuid'].to_s }
25
+
26
+ info do
27
+ {
28
+ 'nickname' => raw_info['username'],
29
+ 'email' => primary_email,
30
+ 'name' => raw_info['display_name'],
31
+ 'image' => raw_info['links']['avatar']['href'],
32
+ }
33
+ end
34
+
35
+ extra do
36
+ {:raw_info => raw_info, :all_emails => emails}
37
+ end
38
+
39
+ def raw_info
40
+ @raw_info ||= access_token.get('user').parsed
41
+ end
42
+
43
+ def primary_email
44
+ primary = emails.find{ |i| i['is_primary'] && i['is_confirmed'] }
45
+ primary && primary['email'] || nil
46
+ end
47
+
48
+ def emails
49
+ email_response = access_token.get('user/emails').parsed
50
+ @emails ||= email_response && email_response['values'] || nil
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ OmniAuth.config.add_camelization 'bitbucket', 'Bitbucket2'
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-bitbucket2/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ["Barnabas Birmacher"]
7
+ gem.email = ["birmacher@gmail.com"]
8
+ gem.description = %q{OmniAuth strategy for Bitbucket.}
9
+ gem.summary = %q{OmniAuth strategy for Bitbucket.}
10
+ gem.homepage = "https://github.com/birmacher/omniauth-bitbucket2"
11
+ gem.license = 'MIT'
12
+
13
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ gem.name = "omniauth-bitbucket2"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = OmniAuth::Bitbucket2::VERSION
19
+
20
+ gem.add_dependency 'omniauth', '~> 1.0'
21
+ # Nothing lower than omniauth-oauth2 1.1.1
22
+ # http://www.rubysec.com/advisories/CVE-2012-6134/
23
+ gem.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
24
+ gem.add_development_dependency 'rspec', '~> 2.7'
25
+ gem.add_development_dependency 'rack-test'
26
+ gem.add_development_dependency 'simplecov'
27
+ gem.add_development_dependency 'webmock'
28
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Bitbucket2 do
4
+ let(:access_token) { double('AccessToken', :options => {}) }
5
+ let(:parsed_response) { double('ParsedResponse') }
6
+ let(:response) { double('Response', :parsed => parsed_response) }
7
+
8
+ subject do
9
+ OmniAuth::Strategies::Bitbucket2.new({})
10
+ end
11
+
12
+ before(:each) do
13
+ subject.stub!(:access_token).and_return(access_token)
14
+ end
15
+
16
+ context "client options" do
17
+ it 'should have correct site' do
18
+ subject.options.client_options.site.should eq("https://api.bitbucket.org/2.0")
19
+ end
20
+
21
+ it 'should have correct authorize url' do
22
+ subject.options.client_options.authorize_url.should eq('https://bitbucket.org/site/oauth2/authorize')
23
+ end
24
+
25
+ it 'should have correct token url' do
26
+ subject.options.client_options.token_url.should eq('https://bitbucket.org/site/oauth2/access_token')
27
+ end
28
+
29
+ it 'should have the correct callback path' do
30
+ expect(subject.callback_path).to eq('/auth/bitbucket/callback')
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-bitbucket2'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-bitbucket2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Barnabas Birmacher
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.1
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.1
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.7'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rack-test
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: simplecov
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: webmock
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ description: OmniAuth strategy for Bitbucket.
104
+ email:
105
+ - birmacher@gmail.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - Gemfile
113
+ - Guardfile
114
+ - LICENSE
115
+ - Rakefile
116
+ - Readme.md
117
+ - lib/omniauth-bitbucket2.rb
118
+ - lib/omniauth-bitbucket2/version.rb
119
+ - lib/omniauth/strategies/bitbucket2.rb
120
+ - omniauth-bitbucket2.gemspec
121
+ - spec/omniauth/strategies/bitbucket2_spec.rb
122
+ - spec/spec_helper.rb
123
+ homepage: https://github.com/birmacher/omniauth-bitbucket2
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.2.2
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: OmniAuth strategy for Bitbucket.
147
+ test_files:
148
+ - spec/omniauth/strategies/bitbucket2_spec.rb
149
+ - spec/spec_helper.rb
150
+ has_rdoc: