Permalink
Browse files

Merging master.

  • Loading branch information...
2 parents 6748a0c + e015844 commit 3dbfdff12742d3517a9add28701986236dfb70be Michael Bleigh committed Sep 3, 2011
Showing with 2,204 additions and 241 deletions.
  1. +0 −9 .autotest
  2. +3 −0 .travis.yml
  3. +27 −0 Guardfile
  4. +19 −0 LICENSE
  5. +17 −32 README.md
  6. 0 Rakefile
  7. +1 −0 lib/oa-core.rb
  8. +33 −0 lib/omniauth/builder.rb
  9. +140 −0 lib/omniauth/core.rb
  10. +186 −0 lib/omniauth/form.rb
  11. +230 −0 lib/omniauth/strategy.rb
  12. +12 −0 lib/omniauth/test.rb
  13. +8 −0 lib/omniauth/test/phony_session.rb
  14. +34 −0 lib/omniauth/test/strategy_macros.rb
  15. +49 −0 lib/omniauth/test/strategy_test_case.rb
  16. +10 −5 oa-core/lib/omniauth/core.rb
  17. +1 −1 oa-core/lib/omniauth/strategy.rb
  18. +8 −9 oa-core/oa-core.gemspec
  19. +5 −0 oa-core/spec/omniauth/strategy_spec.rb
  20. +34 −1 oa-enterprise/README.rdoc
  21. +1 −0 oa-enterprise/lib/omniauth/enterprise.rb
  22. +2 −2 oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb
  23. +50 −0 oa-enterprise/lib/omniauth/strategies/saml.rb
  24. +38 −0 oa-enterprise/lib/omniauth/strategies/saml/auth_request.rb
  25. +141 −0 oa-enterprise/lib/omniauth/strategies/saml/auth_response.rb
  26. +8 −0 oa-enterprise/lib/omniauth/strategies/saml/validation_error.rb
  27. +126 −0 oa-enterprise/lib/omniauth/strategies/saml/xml_security.rb
  28. +19 −19 oa-enterprise/oa-enterprise.gemspec
  29. +37 −0 oa-enterprise/spec/omniauth/strategies/saml_spec.rb
  30. +0 −1 oa-identity/oa-identity.gemspec
  31. +4 −5 oa-more/lib/omniauth/more.rb
  32. +0 −86 oa-more/lib/omniauth/strategies/flickr.rb
  33. +13 −15 oa-more/oa-more.gemspec
  34. +0 −7 oa-more/spec/omniauth/strategies/flickr_spec.rb
  35. +10 −2 oa-oauth/lib/omniauth/oauth.rb
  36. +59 −0 oa-oauth/lib/omniauth/strategies/google_oauth2.rb
  37. +2 −2 oa-oauth/lib/omniauth/strategies/oauth.rb
  38. +2 −0 oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb
  39. +39 −0 oa-oauth/lib/omniauth/strategies/oauth/flickr.rb
  40. +1 −0 oa-oauth/lib/omniauth/strategies/oauth/t163.rb
  41. +2 −2 oa-oauth/lib/omniauth/strategies/oauth/tsina.rb
  42. +57 −0 oa-oauth/lib/omniauth/strategies/oauth2/angellist.rb
  43. +1 −1 oa-oauth/lib/omniauth/strategies/oauth2/foursquare.rb
  44. +1 −0 oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb
  45. +67 −0 oa-oauth/lib/omniauth/strategies/oauth2/liveid.rb
  46. +39 −0 oa-oauth/lib/omniauth/strategies/oauth2/mailchimp.rb
  47. +3 −0 oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb
  48. +12 −2 oa-oauth/lib/omniauth/strategies/{oauth → oauth2}/sound_cloud.rb
  49. +3 −2 oa-oauth/lib/omniauth/strategies/oauth2/taobao.rb
  50. +72 −0 oa-oauth/lib/omniauth/strategies/oauth2/viadeo.rb
  51. +16 −18 oa-oauth/oa-oauth.gemspec
  52. +5 −0 oa-oauth/spec/omniauth/strategies/google_oauth2_spec.rb
  53. +6 −0 oa-oauth/spec/omniauth/strategies/oauth/flickr_spec.rb
  54. +26 −0 oa-oauth/spec/omniauth/strategies/oauth/oauth_spec.rb
  55. +5 −0 oa-oauth/spec/omniauth/strategies/oauth2/angellist_spec.rb
  56. +5 −0 oa-oauth/spec/omniauth/strategies/oauth2/instagram_spec.rb
  57. +5 −0 oa-oauth/spec/omniauth/strategies/oauth2/liveid_spec.rb
  58. +6 −0 oa-oauth/spec/omniauth/strategies/oauth2/mailchimp_spec.rb
  59. +1 −1 oa-oauth/spec/omniauth/strategies/{oauth → oauth2}/sound_cloud_spec.rb
  60. +1 −1 oa-oauth/spec/omniauth/strategies/oauth2/taobao_spec.rb
  61. +5 −0 oa-oauth/spec/omniauth/strategies/oauth2/viadeo_spec.rb
  62. +4 −2 oa-openid/lib/omniauth/strategies/open_id.rb
  63. +12 −14 oa-openid/oa-openid.gemspec
  64. +2 −2 omniauth.gemspec
  65. +20 −0 spec/omniauth/builder_spec.rb
  66. +79 −0 spec/omniauth/core_spec.rb
  67. +368 −0 spec/omniauth/strategy_spec.rb
  68. +12 −0 spec/spec_helper.rb
View
@@ -1,9 +0,0 @@
-require 'autotest/bundler'
-
-Autotest.add_hook :initialize do |at|
- at.clear_mappings
-
- at.add_mapping(%r{^.*/spec/.*_spec.rb$}) do |filename, _|
- filename
- end
-end
View
@@ -1,4 +1,7 @@
rvm:
- 1.8.7
- 1.9.2
+ - jruby
+ - rbx
+ - rbx-2.0
- ree
View
@@ -0,0 +1,27 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec/" }
+
+ # Rails example
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec/" }
+ watch('spec/spec_helper.rb') { "spec/" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+end
+
+
+guard 'bundler' do
+ watch('Gemfile')
+ # Uncomment next line if Gemfile contain `gemspec' command
+ # watch(/^.+\.gemspec/)
+end
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
+
+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.
View
@@ -1,5 +1,4 @@
-OmniAuth: Standardized Multi-Provider Authentication
-====================================================
+# OmniAuth: Standardized Multi-Provider Authentication
OmniAuth is a new Rack-based authentication system for multi-provider external
authentcation. OmniAuth is built from the ground up on the philosophy that
**authentication is not the same as identity**, and is based on two
@@ -13,22 +12,20 @@ observations:
to one, three, or twelve other services. Modern authentication systems
should allow a user's identity to be associated with many authentications.
-Installation
-------------
+## <a name="installation">Installation</a>
To install OmniAuth, simply install the gem:
gem install omniauth
-Continuous Integration
-----------------------
-[![Build Status](https://secure.travis-ci.org/intridea/omniauth.png)](http://travis-ci.org/intridea/omniauth)
+## <a name="ci">Continuous Integration</a>
+[![Build Status](https://travis-ci.org/intridea/omniauth.png)](http://travis-ci.org/intridea/omniauth)
-Providers
----------
+## <a name="providers">Providers</a>
OmniAuth currently supports the following external providers:
* via OAuth (OAuth 1.0, OAuth 2, and xAuth)
* 37signals ID (credit: [mbleigh](https://github.com/mbleigh))
+ * AngelList (credit: [joshuaxls](https://github.com/joshuaxls))
* Bit.ly (credit: [philnash](https://github.com/philnash))
* Blogger (credit: [dsueiro-backing](https://github.com/dsueiro-backing))
* Cobot (credit: [kamal](https://github.com/kamal))
@@ -51,6 +48,7 @@ OmniAuth currently supports the following external providers:
* Instapaper (credit: [micpringle](https://github.com/micpringle))
* LastFM (credit: [tictoc](https://github.com/tictoc))
* LinkedIn (credit: [mbleigh](https://github.com/mbleigh))
+ * Mailchimp (via [srbiv](http://github.com/srbiv))
* Mailru (credit: [lexer](https://github.com/lexer))
* Meetup (credit [coderoshi](https://github.com/coderoshi))
* Miso (credit: [rickenharp](https://github.com/rickenharp))
@@ -74,6 +72,7 @@ OmniAuth currently supports the following external providers:
* Tsohu (credit: [quake](https://github.com/quake))
* Tumblr (credit: [jamiew](https://github.com/jamiew))
* Twitter (credit: [mbleigh](https://github.com/mbleigh))
+ * Viadeo (credit: [guillaug](https://github.com/guillaug))
* Vimeo (credit: [jamiew](https://github.com/jamiew))
* Vkontakte (credit: [german](https://github.com/german))
* WePay (credit: [ryanwood](https://github.com/ryanwood))
@@ -88,19 +87,7 @@ OmniAuth currently supports the following external providers:
* OpenID (credit: [mbleigh](https://github.com/mbleigh))
* Yupoo (credit: [chouti](https://github.com/chouti))
-Compatibility
--------------
-OmniAuth is tested against the following Ruby versions:
-
-* 1.8.7
-* 1.9.1
-* 1.9.2
-* JRuby (note, the Evernote strategy is not available for JRuby)
-* Rubinius
-* REE
-
-Usage
------
+## <a name="usage">Usage</a>
OmniAuth is a collection of Rack middleware. To use a single strategy, you simply need to add the middleware:
require 'oa-oauth'
@@ -126,8 +113,7 @@ The hash in question will look something like this:
The `user_info` hash will automatically be populated with as much information about the user as OmniAuth was able to pull from the given API or authentication provider.
-Resources
----------
+## <a name="resources">Resources</a>
The best place to find more information is the [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki). Some specific information you might be interested in:
* [CI Build Status](http://travis-ci.org/intridea/omniauth)
@@ -136,20 +122,20 @@ The best place to find more information is the [OmniAuth Wiki](https://github.co
* [Report Issues](https://github.com/intridea/omniauth/issues)
* [Mailing List](http://groups.google.com/group/omniauth)
-OmniAuth Core
--------------
+## <a name="core">Core Team</a>
* **Michael Bleigh** ([mbleigh](https://github.com/mbleigh))
* **Erik Michaels-Ober** ([sferik](https://github.com/sferik))
-Supported Rubies
-----------------
+## <a name="rubies">Supported Rubies</a>
This library aims to support and is [tested
against](http://travis-ci.org/intridea/omniauth) the following Ruby
implementations:
* Ruby 1.8.7
* Ruby 1.9.2
-* Ruby Enterprise Edition 1.8.7
+* [JRuby](http://www.jruby.org/)
+* [Rubinius](http://rubini.us/)
+* [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
If something doesn't work on one of these interpreters, it should be considered
a bug.
@@ -165,6 +151,5 @@ implementation, you will be personally responsible for providing patches in a
timely fashion. If critical issues for a particular implementation exist at the
time of a major release, support for that Ruby version may be dropped.
-License
--------
-OmniAuth is licensed under the MIT License.
+## <a name="license">License</a>
+OmniAuth is released under the MIT License.
View
0 Rakefile 100644 → 100755
No changes.
View
@@ -0,0 +1 @@
+require 'omniauth/core'
View
@@ -0,0 +1,33 @@
+require 'omniauth/core'
+
+module OmniAuth
+ class Builder < ::Rack::Builder
+ def initialize(app, &block)
+ @app = app
+ super(&block)
+ end
+
+ def on_failure(&block)
+ OmniAuth.config.on_failure = block
+ end
+
+ def configure(&block)
+ OmniAuth.configure(&block)
+ end
+
+ def provider(klass, *args, &block)
+ if klass.is_a?(Class)
+ middleware = klass
+ else
+ middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
+ end
+
+ use middleware, *args, &block
+ end
+
+ def call(env)
+ @ins << @app unless @ins.include?(@app)
+ to_app.call(env)
+ end
+ end
+end
View
@@ -0,0 +1,140 @@
+require 'rack'
+require 'singleton'
+
+module OmniAuth
+ module Strategies; end
+
+ autoload :Builder, 'omniauth/builder'
+ autoload :Strategy, 'omniauth/strategy'
+ autoload :Test, 'omniauth/test'
+ autoload :Form, 'omniauth/form'
+
+ def self.strategies
+ @@strategies ||= []
+ end
+
+ class Configuration
+ include Singleton
+
+ @@defaults = {
+ :path_prefix => '/auth',
+ :on_failure => Proc.new do |env|
+ message_key = env['omniauth.error.type']
+ new_path = "#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
+ [302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
+ end,
+ :form_css => Form::DEFAULT_CSS,
+ :test_mode => false,
+ :allowed_request_methods => [:get, :post],
+ :mock_auth => {
+ :default => {
+ 'provider' => 'default',
+ 'uid' => '1234',
+ 'user_info' => {
+ 'name' => 'Bob Example'
+ }
+ }
+ }
+ }
+
+ def self.defaults
+ @@defaults
+ end
+
+ def initialize
+ @@defaults.each_pair{|k,v| self.send("#{k}=",v)}
+ end
+
+ def on_failure(&block)
+ if block_given?
+ @on_failure = block
+ else
+ @on_failure
+ end
+ end
+
+ def add_mock(provider, mock={})
+ # Stringify keys recursively one level.
+ mock.keys.each do |key|
+ mock[key.to_s] = mock.delete(key)
+ end
+ mock.each_pair do |key, val|
+ if val.is_a? Hash
+ val.keys.each do |subkey|
+ val[subkey.to_s] = val.delete(subkey)
+ end
+ end
+ end
+
+ # Merge with the default mock and ensure provider is correct.
+ mock = self.mock_auth[:default].dup.merge(mock)
+ mock["provider"] = provider.to_s
+
+ # Add it to the mocks.
+ self.mock_auth[provider.to_sym] = mock
+ end
+
+ attr_writer :on_failure
+ attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host
+ end
+
+ def self.config
+ Configuration.instance
+ end
+
+ def self.configure
+ yield config
+ end
+
+ def self.mock_auth_for(provider)
+ config.mock_auth[provider.to_sym] || config.mock_auth[:default]
+ end
+
+ module Utils
+ CAMELIZE_SPECIAL = {
+ 'oauth' => 'OAuth',
+ 'oauth2' => 'OAuth2',
+ 'openid' => 'OpenID',
+ 'open_id' => 'OpenID',
+ 'github' => 'GitHub',
+ 'tripit' => 'TripIt',
+ 'soundcloud' => 'SoundCloud',
+ 'smugmug' => 'SmugMug',
+ 'cas' => 'CAS',
+ 'trademe' => 'TradeMe',
+ 'ldap' => 'LDAP',
+ 'google_oauth2' => 'GoogleOAuth2'
+ }
+
+ module_function
+
+ def form_css
+ "<style type='text/css'>#{OmniAuth.config.form_css}</style>"
+ end
+
+ def deep_merge(hash, other_hash)
+ target = hash.dup
+
+ other_hash.keys.each do |key|
+ if other_hash[key].is_a? ::Hash and hash[key].is_a? ::Hash
+ target[key] = deep_merge(target[key],other_hash[key])
+ next
+ end
+
+ target[key] = other_hash[key]
+ end
+
+ target
+ end
+
+ def camelize(word, first_letter_in_uppercase = true)
+ return CAMELIZE_SPECIAL[word.to_s] if CAMELIZE_SPECIAL[word.to_s]
+
+ if first_letter_in_uppercase
+ word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
+ else
+ word.first + camelize(word)[1..-1]
+ end
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 3dbfdff

Please sign in to comment.