Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bundler's add_bundler_dependencies is considered harmful and being de…

…precated; changed from Gemfile -> .gemspec dependencies to the reverse.
  • Loading branch information...
commit f4919a113acc0e28dfe655bcb2f1e0c626976536 1 parent 67d752a
James Alexander Rosen jamesarosen authored

Showing 26 changed files with 322 additions and 57 deletions. Show diff stats Hide diff stats

  1. +0 30 Gemfile
  2. +2 4 Rakefile
  3. +20 0 development_dependencies.rb
  4. +9 0 oa-basic/Gemfile
  5. +1 3 oa-basic/Rakefile
  6. +3 0  oa-basic/dist/oa-basic-0.0.3/CHANGELOG.rdoc
  7. 0  oa-basic/dist/oa-basic-0.0.3/LICENSE.rdoc
  8. +34 0 oa-basic/dist/oa-basic-0.0.3/README.rdoc
  9. +10 0 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/basic.rb
  10. +55 0 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/strategies/basecamp.rb
  11. +47 0 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/strategies/campfire.rb
  12. +19 0 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/strategies/gowalla.rb
  13. +56 0 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/strategies/http_basic.rb
  14. +6 3 oa-basic/oa-basic.gemspec
  15. +7 0 oa-core/Gemfile
  16. +1 3 oa-core/Rakefile
  17. +3 1 oa-core/oa-core.gemspec
  18. +9 0 oa-oauth/Gemfile
  19. +1 3 oa-oauth/Rakefile
  20. +10 2 oa-oauth/oa-oauth.gemspec
  21. +9 0 oa-openid/Gemfile
  22. +1 3 oa-openid/Rakefile
  23. +4 2 oa-openid/oa-openid.gemspec
  24. +12 0 omniauth/Gemfile
  25. +1 1  omniauth/Rakefile
  26. +2 2 omniauth/omniauth.gemspec
30 Gemfile
... ... @@ -1,30 +0,0 @@
1   -source "http://rubygems.org"
2   -
3   -gem 'rack', '~> 1.1.0'
4   -
5   -group :oa_basic, :oa_oauth do
6   - gem 'json', '~> 1.4.3'
7   - gem 'nokogiri', '~> 1.4.2'
8   -end
9   -
10   -group :oa_basic do
11   - gem 'rest-client', '~> 1.5.1', :require => 'restclient'
12   -end
13   -
14   -group :oa_oauth do
15   - gem 'oauth', '~> 0.4.0'
16   - gem 'oauth2', '~> 0.0.8'
17   -end
18   -
19   -group :oa_openid do
20   - gem 'rack-openid', '~> 1.0.3', :require => 'rack/openid'
21   -end
22   -
23   -group :development do
24   - gem 'rake'
25   - gem 'mg', '~> 0.0.8'
26   - gem 'term-ansicolor', :require => 'term/ansicolor'
27   - gem 'rspec', '~> 1.3.0', :require => 'spec'
28   - gem 'webmock', '~> 1.2.2'
29   - gem 'rack-test', '~> 0.5.4', :require => 'rack/test'
30   -end
6 Rakefile
... ... @@ -1,6 +1,4 @@
1 1 require 'rubygems'
2   -require 'bundler'
3   -Bundler.setup(:development)
4 2 require 'rake'
5 3 require 'term/ansicolor'
6 4
@@ -59,14 +57,14 @@ namespace :gems do
59 57 task :build do
60 58 each_gem('is building gems...') do
61 59 system('rake gem')
62   - end
  60 + end
63 61 end
64 62
65 63 desc 'Push all gems to Gemcutter'
66 64 task :release do
67 65 each_gem('is releasing to Gemcutter...') do
68 66 system('rake gemcutter')
69   - end
  67 + end
70 68 end
71 69
72 70 desc 'Install all gems'
20 development_dependencies.rb
... ... @@ -0,0 +1,20 @@
  1 +# to be evaluated within the context of a Gemspec or a Gemfile
  2 +
  3 +# It's ridiculous that Bundler can't sync up with .gemspec files for
  4 +# development dependencies. Until it can, make sure to keep these
  5 +# two blocks parallel.
  6 +if Object.const_defined?(:Bundler) && Bundler.const_defined?(:Dsl) && self.kind_of?(Bundler::Dsl)
  7 + group :development do
  8 + gem 'rake'
  9 + gem 'mg', '~> 0.0.8'
  10 + gem 'rspec', '~> 1.3.0'
  11 + gem 'webmock', '~> 1.2.2'
  12 + gem 'rack-test', '~> 0.5.4'
  13 + end
  14 +else #gemspec
  15 + gem.add_development_dependency 'rake'
  16 + gem.add_development_dependency 'mg', '~> 0.0.8'
  17 + gem.add_development_dependency 'rspec', '~> 1.3.0'
  18 + gem.add_development_dependency 'webmock', '~> 1.2.2'
  19 + gem.add_development_dependency 'rack-test', '~> 0.5.4'
  20 +end
9 oa-basic/Gemfile
... ... @@ -0,0 +1,9 @@
  1 +source "http://rubygems.org"
  2 +
  3 +gem 'oa-core', :path => File.expand_path('../../oa-core/', __FILE__)
  4 +
  5 +# Will automatically pull in this gem and all its
  6 +# dependencies specified in the gemspec
  7 +gem 'oa-basic', :path => File.expand_path("..", __FILE__)
  8 +
  9 +eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
4 oa-basic/Rakefile
... ... @@ -1,8 +1,6 @@
1   -ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
2   -
3 1 require 'rubygems'
4 2 require 'bundler'
5   -Bundler.setup(:default, :development, :test, :oa_basic)
  3 +Bundler.setup
6 4 require 'rake'
7 5
8 6 require 'mg'
3  oa-basic/dist/oa-basic-0.0.3/CHANGELOG.rdoc
Source Rendered
... ... @@ -0,0 +1,3 @@
  1 +== 0.0.3
  2 +
  3 +* First working release, Campfire and Basecamp support
0  oa-basic/dist/oa-basic-0.0.3/LICENSE.rdoc
Source Rendered
No changes.
34 oa-basic/dist/oa-basic-0.0.3/README.rdoc
Source Rendered
... ... @@ -0,0 +1,34 @@
  1 += OmniAuth::Basic
  2 +
  3 +OmniAuth stratgies for APIs that have HTTP Basic authentication (such as Campfire and Basecamp).
  4 +
  5 +== Installation
  6 +
  7 +To get just HTTP Basic functionality:
  8 +
  9 + gem install oa-basic
  10 +
  11 +For the full auth suite:
  12 +
  13 + gem install omniauth
  14 +
  15 +== Stand-Alone Example
  16 +
  17 +Use the strategy as a middleware in your application:
  18 +
  19 + require 'omniauth/basic'
  20 +
  21 + use OmniAuth::Strategies::Campfire
  22 +
  23 +Then simply direct users to '/auth/campfire' to prompt them for their Campfire credentials. You may also pre-set the credentials by POSTing to the URL with appropriate parameters (in the case of Campfire and Basecamp, the parameters are <tt>subdomain</tt>, <tt>user</tt>, and <tt>password</tt>).
  24 +
  25 +== OmniAuth Builder
  26 +
  27 +If you want to allow multiple providers, use the OmniAuth Builder:
  28 +
  29 + require 'omniauth/basic'
  30 +
  31 + use OmniAuth::Builder do
  32 + provider :campfire
  33 + provider :basecamp
  34 + end
10 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/basic.rb
... ... @@ -0,0 +1,10 @@
  1 +require 'omniauth/core'
  2 +
  3 +module OmniAuth
  4 + module Strategies
  5 + autoload :HttpBasic, 'omniauth/strategies/http_basic'
  6 + autoload :Basecamp, 'omniauth/strategies/basecamp'
  7 + autoload :Campfire, 'omniauth/strategies/campfire'
  8 + # autoload :Gowalla, 'omniauth/strategies/gowalla'
  9 + end
  10 +end
55 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/strategies/basecamp.rb
... ... @@ -0,0 +1,55 @@
  1 +require 'omniauth/basic'
  2 +
  3 +module OmniAuth
  4 + module Strategies
  5 + class Basecamp < HttpBasic
  6 + def initialize(app)
  7 + require 'json'
  8 + super(app, :basecamp, nil)
  9 + end
  10 +
  11 + def endpoint
  12 + "http://#{request.params['user']}:#{request.params['password']}@#{request.params['subdomain']}.basecamphq.com/me.xml"
  13 + end
  14 +
  15 + def perform_authentication(endpoint)
  16 + super(endpoint) rescue super(endpoint.sub('http','https'))
  17 + end
  18 +
  19 + def auth_hash
  20 + doc = Nokogiri::XML.parse(@response.body)
  21 + OmniAuth::Utils.deep_merge(super, {
  22 + 'uid' => doc.xpath('person/id').text,
  23 + 'user_info' => user_info(doc),
  24 + 'credentials' => {
  25 + 'token' => doc.xpath('person/token').text
  26 + }
  27 + })
  28 + end
  29 +
  30 + def user_info(doc)
  31 + hash = {
  32 + 'nickname' => request.params['user'],
  33 + 'first_name' => doc.xpath('person/first-name').text,
  34 + 'last_name' => doc.xpath('person/last-name').text,
  35 + 'email' => doc.xpath('person/email-address').text,
  36 + 'image' => doc.xpath('person/avatar-url').text
  37 + }
  38 +
  39 + hash['name'] = [hash['first_name'], hash['last_name']].join(' ').strip
  40 +
  41 + hash.delete('image') if hash['image'].include?('missing/avatar.png')
  42 +
  43 + hash
  44 + end
  45 +
  46 + def get_credentials
  47 + OmniAuth::Form.build('Basecamp Authentication') do
  48 + text_field 'Subdomain', 'subdomain'
  49 + text_field 'Username', 'user'
  50 + password_field 'Password', 'password'
  51 + end.to_response
  52 + end
  53 + end
  54 + end
  55 +end
47 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/strategies/campfire.rb
... ... @@ -0,0 +1,47 @@
  1 +require 'omniauth/basic'
  2 +
  3 +module OmniAuth
  4 + module Strategies
  5 + class Campfire < HttpBasic
  6 + def initialize(app)
  7 + require 'json'
  8 + super(app, :campfire, nil)
  9 + end
  10 +
  11 + def endpoint
  12 + "http://#{request.params['user']}:#{request.params['password']}@#{request.params['subdomain']}.campfirenow.com/users/me.json"
  13 + end
  14 +
  15 + def perform_authentication(endpoint)
  16 + super(endpoint) rescue super(endpoint.sub('http','https'))
  17 + end
  18 +
  19 + def auth_hash
  20 + user_hash = JSON.parse(@response.body)['user']
  21 + OmniAuth::Utils.deep_merge(super, {
  22 + 'uid' => user_hash['id'],
  23 + 'user_info' => user_info(user_hash),
  24 + 'credentials' => {
  25 + 'token' => user_hash['api_auth_token']
  26 + }
  27 + })
  28 + end
  29 +
  30 + def user_info(hash)
  31 + {
  32 + 'nickname' => request.params['user'],
  33 + 'name' => hash['name'],
  34 + 'email' => hash['email_address']
  35 + }
  36 + end
  37 +
  38 + def get_credentials
  39 + OmniAuth::Form.build('Campfire Authentication') do
  40 + text_field 'Subdomain', 'subdomain'
  41 + text_field 'Username', 'user'
  42 + password_field 'Password', 'password'
  43 + end.to_response
  44 + end
  45 + end
  46 + end
  47 +end
19 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/strategies/gowalla.rb
... ... @@ -0,0 +1,19 @@
  1 +# Gowalla's API isn't authenticated yet
  2 +# so this won't actually work at all it
  3 +# turns out.
  4 +
  5 +# require 'omniauth/basic'
  6 +#
  7 +# module OmniAuth
  8 +# module Strategies
  9 +# class Gowalla < OmniAuth::Strategies::HttpBasic #:nodoc:
  10 +# def initialize(app, api_key)
  11 +# super(app, :gowalla, nil, {'X-Gowalla-API-Key' => api_key, 'Accept' => 'application/json'})
  12 +# end
  13 +#
  14 +# def endpoint
  15 +# "http://#{request[:username]}:#{request[:password]}@api.gowalla.com/users/#{request[:username]}"
  16 +# end
  17 +# end
  18 +# end
  19 +# end
56 oa-basic/dist/oa-basic-0.0.3/lib/omniauth/strategies/http_basic.rb
... ... @@ -0,0 +1,56 @@
  1 +require 'restclient'
  2 +require 'omniauth/basic'
  3 +
  4 +module OmniAuth
  5 + module Strategies
  6 + class HttpBasic
  7 + include OmniAuth::Strategy
  8 +
  9 + def initialize(app, name, endpoint, headers = {})
  10 + super
  11 + @endpoint = endpoint
  12 + @request_headers = headers
  13 + end
  14 +
  15 + attr_reader :endpoint, :request_headers
  16 +
  17 + def request_phase
  18 + if env['REQUEST_METHOD'] == 'GET'
  19 + get_credentials
  20 + else
  21 + perform
  22 + end
  23 + end
  24 +
  25 + def title
  26 + name.split('_').map{|s| s.capitalize}.join(' ')
  27 + end
  28 +
  29 + def get_credentials
  30 + OmniAuth::Form.build(title) do
  31 + text_field 'Username', 'username'
  32 + password_field 'Password', 'password'
  33 + end.to_response
  34 + end
  35 +
  36 + def perform
  37 + @response = perform_authentication(endpoint)
  38 + request.POST['auth'] = auth_hash
  39 + @env['REQUEST_METHOD'] = 'GET'
  40 + @env['PATH_INFO'] = "#{OmniAuth.config.path_prefix}/#{name}/callback"
  41 +
  42 + @app.call(@env)
  43 + rescue RestClient::Request::Unauthorized
  44 + fail!(:invalid_credentials)
  45 + end
  46 +
  47 + def perform_authentication(uri, headers = request_headers)
  48 + RestClient.get(uri, headers)
  49 + end
  50 +
  51 + def callback_phase
  52 + fail!(:invalid_credentials)
  53 + end
  54 + end
  55 + end
  56 +end
9 oa-basic/oa-basic.gemspec
... ... @@ -1,5 +1,4 @@
1 1 require 'rubygems'
2   -require 'bundler'
3 2
4 3 version = File.open(File.dirname(__FILE__) + '/../VERSION', 'r').read.strip
5 4
@@ -14,6 +13,10 @@ Gem::Specification.new do |gem|
14 13
15 14 gem.files = Dir.glob("{lib}/**/*") + %w(README.rdoc LICENSE.rdoc CHANGELOG.rdoc)
16 15
17   - gem.add_dependency 'oa-core', version
18   - gem.add_bundler_dependencies(:default, :oa_basic, :development)
  16 + gem.add_dependency 'oa-core', version
  17 + gem.add_dependency 'rest-client', '~> 1.5.1'
  18 + gem.add_dependency 'json', '~> 1.4.3'
  19 + gem.add_dependency 'nokogiri', '~> 1.4.2'
  20 +
  21 + eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
19 22 end
7 oa-core/Gemfile
... ... @@ -0,0 +1,7 @@
  1 +source "http://rubygems.org"
  2 +
  3 +# Will automatically pull in this gem and all its
  4 +# dependencies specified in the gemspec
  5 +gem 'oa-core', :path => File.expand_path("..", __FILE__)
  6 +
  7 +eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
4 oa-core/Rakefile
... ... @@ -1,8 +1,6 @@
1   -ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
2   -
3 1 require 'rubygems'
4 2 require 'bundler'
5   -Bundler.setup(:default, :development, :test)
  3 +Bundler.setup
6 4 require 'rake'
7 5
8 6 require 'mg'
4 oa-core/oa-core.gemspec
@@ -11,5 +11,7 @@ Gem::Specification.new do |gem|
11 11
12 12 gem.files = Dir.glob("{lib}/**/*") + %w(LICENSE.rdoc CHANGELOG.rdoc)
13 13
14   - gem.add_bundler_dependencies(:default, :oa_core, :development)
  14 + gem.add_dependency 'rack', '~> 1.1.0'
  15 +
  16 + eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
15 17 end
9 oa-oauth/Gemfile
... ... @@ -0,0 +1,9 @@
  1 +source "http://rubygems.org"
  2 +
  3 +gem 'oa-core', :path => File.expand_path('../../oa-core/', __FILE__)
  4 +
  5 +# Will automatically pull in this gem and all its
  6 +# dependencies specified in the gemspec
  7 +gem 'oa-oauth', :path => File.expand_path("..", __FILE__)
  8 +
  9 +eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
4 oa-oauth/Rakefile
... ... @@ -1,8 +1,6 @@
1   -ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
2   -
3 1 require 'rubygems'
4 2 require 'bundler'
5   -Bundler.setup(:default, :development, :test, :oa_oauth)
  3 +Bundler.setup
6 4 require 'rake'
7 5
8 6 require 'mg'
12 oa-oauth/oa-oauth.gemspec
... ... @@ -1,3 +1,5 @@
  1 +require 'rubygems'
  2 +
1 3 version = File.open(File.dirname(__FILE__) + '/../VERSION', 'r').read.strip
2 4
3 5 Gem::Specification.new do |gem|
@@ -11,6 +13,12 @@ Gem::Specification.new do |gem|
11 13
12 14 gem.files = Dir.glob("{lib}/**/*") + %w(README.rdoc LICENSE.rdoc CHANGELOG.rdoc)
13 15
14   - gem.add_dependency 'oa-core', version
15   - gem.add_bundler_dependencies(:default, :oa_oauth, :development)
  16 + gem.add_dependency 'oa-core', version
  17 + gem.add_dependency 'rack', '~> 1.1.0'
  18 + gem.add_dependency 'json', '~> 1.4.3'
  19 + gem.add_dependency 'nokogiri', '~> 1.4.2'
  20 + gem.add_dependency 'oauth', '~> 0.4.0'
  21 + gem.add_dependency 'oauth2', '~> 0.0.8'
  22 +
  23 + eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
16 24 end
9 oa-openid/Gemfile
... ... @@ -0,0 +1,9 @@
  1 +source "http://rubygems.org"
  2 +
  3 +gem 'oa-core', :path => File.expand_path('../../oa-core/', __FILE__)
  4 +
  5 +# Will automatically pull in this gem and all its
  6 +# dependencies specified in the gemspec
  7 +gem 'oa-openid', :path => File.expand_path("..", __FILE__)
  8 +
  9 +eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
4 oa-openid/Rakefile
... ... @@ -1,8 +1,6 @@
1   -ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
2   -
3 1 require 'rubygems'
4 2 require 'bundler'
5   -Bundler.setup(:default, :development, :test, :oa_openid)
  3 +Bundler.setup
6 4 require 'rake'
7 5
8 6 require 'mg'
6 oa-openid/oa-openid.gemspec
@@ -11,6 +11,8 @@ Gem::Specification.new do |gem|
11 11
12 12 gem.files = Dir.glob("{lib}/**/*") + %w(README.rdoc LICENSE.rdoc CHANGELOG.rdoc)
13 13
14   - gem.add_dependency 'oa-core', version
15   - gem.add_bundler_dependencies(:default, :oa_openid, :development)
  14 + gem.add_dependency 'oa-core', version
  15 + gem.add_dependency 'rack-openid', '~> 1.0.3'
  16 +
  17 + eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
16 18 end
12 omniauth/Gemfile
... ... @@ -0,0 +1,12 @@
  1 +source "http://rubygems.org"
  2 +
  3 +gem 'oa-core', :path => File.expand_path('../../oa-core/', __FILE__)
  4 +gem 'oa-basic', :path => File.expand_path('../../oa-basic/', __FILE__)
  5 +gem 'oa-oauth', :path => File.expand_path('../../oa-oauth/', __FILE__)
  6 +gem 'oa-openid', :path => File.expand_path('../../oa-openid/', __FILE__)
  7 +
  8 +# Will automatically pull in this gem and all its
  9 +# dependencies specified in the gemspec
  10 +gem 'omniauth', :path => File.expand_path("..", __FILE__)
  11 +
  12 +eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
2  omniauth/Rakefile
... ... @@ -1,6 +1,6 @@
1 1 require 'rubygems'
2 2 require 'bundler'
3   -Bundler.setup(:default, :development, :test)
  3 +Bundler.setup
4 4 require 'rake'
5 5
6 6 require 'mg'
4 omniauth/omniauth.gemspec
@@ -14,6 +14,6 @@ Gem::Specification.new do |gem|
14 14 %w(oa-core oa-oauth oa-basic oa-openid).each do |subgem|
15 15 gem.add_dependency subgem, version
16 16 end
17   -
18   - gem.add_bundler_dependencies(:development)
  17 +
  18 + eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
19 19 end

0 comments on commit f4919a1

Please sign in to comment.
Something went wrong with that request. Please try again.