omniauth 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of omniauth might be problematic. Click here for more details.

Files changed (197) hide show
  1. data/.autotest +9 -0
  2. data/.document +5 -0
  3. data/.gitignore +36 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +7 -0
  6. data/.yardopts +4 -0
  7. data/Gemfile +6 -1
  8. data/README.markdown +121 -0
  9. data/Rakefile +50 -2
  10. data/lib/omniauth/version.rb +18 -4
  11. data/oa-basic/.gemtest +0 -0
  12. data/oa-basic/.rspec +3 -0
  13. data/oa-basic/.yardopts +4 -0
  14. data/oa-basic/LICENSE +19 -0
  15. data/oa-basic/README.rdoc +34 -0
  16. data/oa-basic/Rakefile +6 -0
  17. data/oa-basic/lib/oa-basic.rb +1 -0
  18. data/oa-basic/lib/omniauth/basic.rb +8 -0
  19. data/oa-basic/lib/omniauth/strategies/http_basic.rb +56 -0
  20. data/oa-basic/lib/omniauth/version.rb +19 -0
  21. data/oa-basic/oa-basic.gemspec +28 -0
  22. data/oa-basic/spec/omniauth/strategies/basic_spec.rb +7 -0
  23. data/oa-basic/spec/spec_helper.rb +11 -0
  24. data/oa-core/.gemtest +0 -0
  25. data/oa-core/.rspec +3 -0
  26. data/oa-core/.yardopts +4 -0
  27. data/oa-core/LICENSE +19 -0
  28. data/oa-core/Rakefile +6 -0
  29. data/oa-core/autotest/discover.rb +1 -0
  30. data/oa-core/lib/oa-core.rb +1 -0
  31. data/oa-core/lib/omniauth/builder.rb +33 -0
  32. data/oa-core/lib/omniauth/core.rb +135 -0
  33. data/oa-core/lib/omniauth/form.rb +184 -0
  34. data/oa-core/lib/omniauth/strategy.rb +227 -0
  35. data/oa-core/lib/omniauth/test.rb +12 -0
  36. data/oa-core/lib/omniauth/test/phony_session.rb +8 -0
  37. data/oa-core/lib/omniauth/test/strategy_macros.rb +34 -0
  38. data/oa-core/lib/omniauth/test/strategy_test_case.rb +49 -0
  39. data/oa-core/lib/omniauth/version.rb +19 -0
  40. data/oa-core/oa-core.gemspec +24 -0
  41. data/oa-core/spec/omniauth/builder_spec.rb +20 -0
  42. data/oa-core/spec/omniauth/core_spec.rb +79 -0
  43. data/oa-core/spec/omniauth/strategy_spec.rb +358 -0
  44. data/oa-core/spec/spec_helper.rb +12 -0
  45. data/oa-enterprise/.gemtest +0 -0
  46. data/oa-enterprise/.rspec +3 -0
  47. data/oa-enterprise/.yardopts +4 -0
  48. data/oa-enterprise/LICENSE +19 -0
  49. data/oa-enterprise/README.rdoc +82 -0
  50. data/oa-enterprise/Rakefile +6 -0
  51. data/oa-enterprise/lib/oa-enterprise.rb +1 -0
  52. data/oa-enterprise/lib/omniauth/enterprise.rb +8 -0
  53. data/oa-enterprise/lib/omniauth/strategies/cas.rb +47 -0
  54. data/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +98 -0
  55. data/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +84 -0
  56. data/oa-enterprise/lib/omniauth/strategies/ldap.rb +111 -0
  57. data/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +279 -0
  58. data/oa-enterprise/lib/omniauth/version.rb +19 -0
  59. data/oa-enterprise/oa-enterprise.gemspec +32 -0
  60. data/oa-enterprise/spec/fixtures/cas_failure.xml +4 -0
  61. data/oa-enterprise/spec/fixtures/cas_success.xml +8 -0
  62. data/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +94 -0
  63. data/oa-enterprise/spec/spec_helper.rb +14 -0
  64. data/oa-more/.gemtest +0 -0
  65. data/oa-more/.rspec +3 -0
  66. data/oa-more/.yardopts +4 -0
  67. data/oa-more/LICENSE +19 -0
  68. data/oa-more/README.rdoc +22 -0
  69. data/oa-more/Rakefile +6 -0
  70. data/oa-more/lib/oa-more.rb +1 -0
  71. data/oa-more/lib/omniauth/more.rb +9 -0
  72. data/oa-more/lib/omniauth/strategies/flickr.rb +86 -0
  73. data/oa-more/lib/omniauth/strategies/windows_live.rb +39 -0
  74. data/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +1143 -0
  75. data/oa-more/lib/omniauth/strategies/yupoo.rb +67 -0
  76. data/oa-more/lib/omniauth/version.rb +19 -0
  77. data/oa-more/oa-more.gemspec +30 -0
  78. data/oa-more/spec/omniauth/strategies/flickr_spec.rb +7 -0
  79. data/oa-more/spec/spec_helper.rb +11 -0
  80. data/oa-oauth/.gemtest +0 -0
  81. data/oa-oauth/.rspec +3 -0
  82. data/oa-oauth/.yardopts +4 -0
  83. data/oa-oauth/LICENSE +19 -0
  84. data/oa-oauth/README.rdoc +35 -0
  85. data/oa-oauth/Rakefile +6 -0
  86. data/oa-oauth/autotest/discover.rb +1 -0
  87. data/oa-oauth/lib/oa-oauth.rb +1 -0
  88. data/oa-oauth/lib/omniauth/oauth.rb +53 -0
  89. data/oa-oauth/lib/omniauth/strategies/bitly.rb +46 -0
  90. data/oa-oauth/lib/omniauth/strategies/dailymile.rb +64 -0
  91. data/oa-oauth/lib/omniauth/strategies/doit.rb +60 -0
  92. data/oa-oauth/lib/omniauth/strategies/dopplr.rb +53 -0
  93. data/oa-oauth/lib/omniauth/strategies/douban.rb +60 -0
  94. data/oa-oauth/lib/omniauth/strategies/evernote.rb +54 -0
  95. data/oa-oauth/lib/omniauth/strategies/facebook.rb +70 -0
  96. data/oa-oauth/lib/omniauth/strategies/foursquare.rb +62 -0
  97. data/oa-oauth/lib/omniauth/strategies/github.rb +50 -0
  98. data/oa-oauth/lib/omniauth/strategies/goodreads.rb +44 -0
  99. data/oa-oauth/lib/omniauth/strategies/google.rb +80 -0
  100. data/oa-oauth/lib/omniauth/strategies/gowalla.rb +64 -0
  101. data/oa-oauth/lib/omniauth/strategies/hyves.rb +67 -0
  102. data/oa-oauth/lib/omniauth/strategies/identica.rb +49 -0
  103. data/oa-oauth/lib/omniauth/strategies/instagram.rb +56 -0
  104. data/oa-oauth/lib/omniauth/strategies/instapaper.rb +40 -0
  105. data/oa-oauth/lib/omniauth/strategies/linked_in.rb +55 -0
  106. data/oa-oauth/lib/omniauth/strategies/meetup.rb +56 -0
  107. data/oa-oauth/lib/omniauth/strategies/miso.rb +41 -0
  108. data/oa-oauth/lib/omniauth/strategies/mixi.rb +59 -0
  109. data/oa-oauth/lib/omniauth/strategies/netflix.rb +65 -0
  110. data/oa-oauth/lib/omniauth/strategies/oauth.rb +85 -0
  111. data/oa-oauth/lib/omniauth/strategies/oauth2.rb +98 -0
  112. data/oa-oauth/lib/omniauth/strategies/qzone.rb +69 -0
  113. data/oa-oauth/lib/omniauth/strategies/rdio.rb +45 -0
  114. data/oa-oauth/lib/omniauth/strategies/renren.rb +87 -0
  115. data/oa-oauth/lib/omniauth/strategies/salesforce.rb +44 -0
  116. data/oa-oauth/lib/omniauth/strategies/smug_mug.rb +42 -0
  117. data/oa-oauth/lib/omniauth/strategies/sound_cloud.rb +46 -0
  118. data/oa-oauth/lib/omniauth/strategies/t163.rb +57 -0
  119. data/oa-oauth/lib/omniauth/strategies/teambox.rb +49 -0
  120. data/oa-oauth/lib/omniauth/strategies/thirty_seven_signals.rb +41 -0
  121. data/oa-oauth/lib/omniauth/strategies/tqq.rb +64 -0
  122. data/oa-oauth/lib/omniauth/strategies/trade_me.rb +45 -0
  123. data/oa-oauth/lib/omniauth/strategies/trip_it.rb +22 -0
  124. data/oa-oauth/lib/omniauth/strategies/tsina.rb +79 -0
  125. data/oa-oauth/lib/omniauth/strategies/tsohu.rb +57 -0
  126. data/oa-oauth/lib/omniauth/strategies/tumblr.rb +60 -0
  127. data/oa-oauth/lib/omniauth/strategies/twitter.rb +57 -0
  128. data/oa-oauth/lib/omniauth/strategies/type_pad.rb +76 -0
  129. data/oa-oauth/lib/omniauth/strategies/vimeo.rb +54 -0
  130. data/oa-oauth/lib/omniauth/strategies/vkontakte.rb +84 -0
  131. data/oa-oauth/lib/omniauth/strategies/xauth.rb +67 -0
  132. data/oa-oauth/lib/omniauth/strategies/yahoo.rb +55 -0
  133. data/oa-oauth/lib/omniauth/strategies/yammer.rb +43 -0
  134. data/oa-oauth/lib/omniauth/strategies/you_tube.rb +73 -0
  135. data/oa-oauth/lib/omniauth/version.rb +19 -0
  136. data/oa-oauth/oa-oauth.gemspec +33 -0
  137. data/oa-oauth/spec/fixtures/basecamp_200.xml +24 -0
  138. data/oa-oauth/spec/fixtures/campfire_200.json +10 -0
  139. data/oa-oauth/spec/omniauth/strategies/bitly_spec.rb +5 -0
  140. data/oa-oauth/spec/omniauth/strategies/dailymile_spec.rb +5 -0
  141. data/oa-oauth/spec/omniauth/strategies/doit_spec.rb +5 -0
  142. data/oa-oauth/spec/omniauth/strategies/dopplr_spec.rb +5 -0
  143. data/oa-oauth/spec/omniauth/strategies/douban_spec.rb +5 -0
  144. data/oa-oauth/spec/omniauth/strategies/evernote_spec.rb +5 -0
  145. data/oa-oauth/spec/omniauth/strategies/facebook_spec.rb +5 -0
  146. data/oa-oauth/spec/omniauth/strategies/foursquare_spec.rb +18 -0
  147. data/oa-oauth/spec/omniauth/strategies/github_spec.rb +5 -0
  148. data/oa-oauth/spec/omniauth/strategies/goodreads_spec.rb +6 -0
  149. data/oa-oauth/spec/omniauth/strategies/google_spec.rb +5 -0
  150. data/oa-oauth/spec/omniauth/strategies/gowalla_spec.rb +5 -0
  151. data/oa-oauth/spec/omniauth/strategies/hyves_spec.rb +5 -0
  152. data/oa-oauth/spec/omniauth/strategies/identica_spec.rb +5 -0
  153. data/oa-oauth/spec/omniauth/strategies/linked_in_spec.rb +5 -0
  154. data/oa-oauth/spec/omniauth/strategies/meetup_spec.rb +14 -0
  155. data/oa-oauth/spec/omniauth/strategies/miso_spec.rb +5 -0
  156. data/oa-oauth/spec/omniauth/strategies/netflix_spec.rb +5 -0
  157. data/oa-oauth/spec/omniauth/strategies/oauth2_spec.rb +0 -0
  158. data/oa-oauth/spec/omniauth/strategies/oauth_spec.rb +77 -0
  159. data/oa-oauth/spec/omniauth/strategies/rdio_spec.rb +5 -0
  160. data/oa-oauth/spec/omniauth/strategies/salesforce_spec.rb +5 -0
  161. data/oa-oauth/spec/omniauth/strategies/smug_mug_spec.rb +5 -0
  162. data/oa-oauth/spec/omniauth/strategies/sound_cloud_spec.rb +5 -0
  163. data/oa-oauth/spec/omniauth/strategies/t163_spec.rb +5 -0
  164. data/oa-oauth/spec/omniauth/strategies/teambox_spec.rb +5 -0
  165. data/oa-oauth/spec/omniauth/strategies/thirty_seven_signals_spec.rb +5 -0
  166. data/oa-oauth/spec/omniauth/strategies/trade_me_spec.rb +5 -0
  167. data/oa-oauth/spec/omniauth/strategies/trip_it_spec.rb +5 -0
  168. data/oa-oauth/spec/omniauth/strategies/tsina_spec.rb +5 -0
  169. data/oa-oauth/spec/omniauth/strategies/tumblr_spec.rb +5 -0
  170. data/oa-oauth/spec/omniauth/strategies/twitter_spec.rb +20 -0
  171. data/oa-oauth/spec/omniauth/strategies/type_pad_spec.rb +5 -0
  172. data/oa-oauth/spec/omniauth/strategies/vimeo_spec.rb +5 -0
  173. data/oa-oauth/spec/omniauth/strategies/vkontakte_spec.rb +5 -0
  174. data/oa-oauth/spec/omniauth/strategies/yahoo_spec.rb +5 -0
  175. data/oa-oauth/spec/omniauth/strategies/yammer_spec.rb +5 -0
  176. data/oa-oauth/spec/omniauth/strategies/you_tube_spec.rb +5 -0
  177. data/oa-oauth/spec/spec_helper.rb +27 -0
  178. data/oa-oauth/spec/support/shared_examples.rb +29 -0
  179. data/oa-openid/.gemtest +0 -0
  180. data/oa-openid/.rspec +3 -0
  181. data/oa-openid/.yardopts +4 -0
  182. data/oa-openid/LICENSE +19 -0
  183. data/oa-openid/README.rdoc +51 -0
  184. data/oa-openid/Rakefile +6 -0
  185. data/oa-openid/lib/oa-openid.rb +1 -0
  186. data/oa-openid/lib/omniauth/openid.rb +59 -0
  187. data/oa-openid/lib/omniauth/openid/gapps.rb +32 -0
  188. data/oa-openid/lib/omniauth/strategies/google_apps.rb +23 -0
  189. data/oa-openid/lib/omniauth/strategies/open_id.rb +132 -0
  190. data/oa-openid/lib/omniauth/version.rb +19 -0
  191. data/oa-openid/oa-openid.gemspec +29 -0
  192. data/oa-openid/spec/omniauth/strategies/open_id_spec.rb +71 -0
  193. data/oa-openid/spec/spec_helper.rb +14 -0
  194. data/omniauth.gemspec +3 -3
  195. data/tasks/all.rb +134 -0
  196. metadata +199 -9
  197. data/README.rdoc +0 -17
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
6
+ gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
7
+ gem.add_runtime_dependency 'rest-client', '~> 1.6.0'
8
+ gem.add_development_dependency 'maruku', '~> 0.6'
9
+ gem.add_development_dependency 'simplecov', '~> 0.4'
10
+ gem.add_development_dependency 'rack-test', '~> 0.5'
11
+ gem.add_development_dependency 'rake', '~> 0.8'
12
+ gem.add_development_dependency 'rspec', '~> 2.5'
13
+ gem.add_development_dependency 'webmock', '~> 1.6'
14
+ gem.add_development_dependency 'yard', '~> 0.6'
15
+ gem.add_development_dependency 'ZenTest', '~> 4.5'
16
+ gem.name = 'oa-basic'
17
+ gem.version = OmniAuth::Version::STRING
18
+ gem.description = %q{HTTP Basic strategies for OmniAuth.}
19
+ gem.summary = gem.description
20
+ gem.email = ['michael@intridea.com', 'sferik@gmail.com']
21
+ gem.homepage = 'http://github.com/intridea/omniauth'
22
+ gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
23
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
24
+ gem.files = `git ls-files`.split("\n")
25
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+ gem.require_paths = ['lib']
27
+ gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
28
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ describe OmniAuth::Strategies::HttpBasic do
4
+ it 'should exist' do
5
+ # do nothing
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+ require 'rspec'
4
+ require 'rack/test'
5
+ require 'webmock/rspec'
6
+ require 'omniauth/basic'
7
+
8
+ RSpec.configure do |config|
9
+ config.include Rack::Test::Methods
10
+ config.include WebMock::API
11
+ end
data/oa-core/.gemtest ADDED
File without changes
data/oa-core/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
data/oa-core/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --markup markdown
2
+ --markup-provider maruku
3
+ -
4
+ LICENSE
data/oa-core/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/oa-core/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
6
+ task :test => :spec
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec2" }
@@ -0,0 +1 @@
1
+ require 'omniauth/core'
@@ -0,0 +1,33 @@
1
+ require 'omniauth/core'
2
+
3
+ module OmniAuth
4
+ class Builder < ::Rack::Builder
5
+ def initialize(app, &block)
6
+ @app = app
7
+ super(&block)
8
+ end
9
+
10
+ def on_failure(&block)
11
+ OmniAuth.config.on_failure = block
12
+ end
13
+
14
+ def configure(&block)
15
+ OmniAuth.configure(&block)
16
+ end
17
+
18
+ def provider(klass, *args, &block)
19
+ if klass.is_a?(Class)
20
+ middleware = klass
21
+ else
22
+ middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
23
+ end
24
+
25
+ use middleware, *args, &block
26
+ end
27
+
28
+ def call(env)
29
+ @ins << @app unless @ins.include?(@app)
30
+ to_app.call(env)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,135 @@
1
+ require 'rack'
2
+ require 'singleton'
3
+
4
+ module OmniAuth
5
+ module Strategies; end
6
+
7
+ autoload :Builder, 'omniauth/builder'
8
+ autoload :Strategy, 'omniauth/strategy'
9
+ autoload :Test, 'omniauth/test'
10
+ autoload :Form, 'omniauth/form'
11
+
12
+ def self.strategies
13
+ @@strategies ||= []
14
+ end
15
+
16
+ class Configuration
17
+ include Singleton
18
+
19
+ @@defaults = {
20
+ :path_prefix => '/auth',
21
+ :on_failure => Proc.new do |env|
22
+ message_key = env['omniauth.error.type']
23
+ new_path = "#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
24
+ [302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
25
+ end,
26
+ :form_css => Form::DEFAULT_CSS,
27
+ :test_mode => false,
28
+ :allowed_request_methods => [:get, :post],
29
+ :mock_auth => {
30
+ :default => {
31
+ 'provider' => 'default',
32
+ 'uid' => '1234',
33
+ 'user_info' => {
34
+ 'name' => 'Bob Example'
35
+ }
36
+ }
37
+ }
38
+ }
39
+
40
+ def self.defaults
41
+ @@defaults
42
+ end
43
+
44
+ def initialize
45
+ @@defaults.each_pair{|k,v| self.send("#{k}=",v)}
46
+ end
47
+
48
+ def on_failure(&block)
49
+ if block_given?
50
+ @on_failure = block
51
+ else
52
+ @on_failure
53
+ end
54
+ end
55
+
56
+ def add_mock(provider, mock={})
57
+ # Stringify keys recursively one level.
58
+ mock.stringify_keys!
59
+ mock.keys.each do|key|
60
+ if mock[key].is_a? Hash
61
+ mock[key].stringify_keys!
62
+ end
63
+ end
64
+
65
+ # Merge with the default mock and ensure provider is correct.
66
+ mock = self.mock_auth[:default].dup.merge(mock)
67
+ mock["provider"] = provider.to_s
68
+
69
+ # Add it to the mocks.
70
+ self.mock_auth[provider.to_sym] = mock
71
+ end
72
+
73
+ attr_writer :on_failure
74
+ attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host
75
+ end
76
+
77
+ def self.config
78
+ Configuration.instance
79
+ end
80
+
81
+ def self.configure
82
+ yield config
83
+ end
84
+
85
+ def self.mock_auth_for(provider)
86
+ config.mock_auth[provider.to_sym] || config.mock_auth[:default]
87
+ end
88
+
89
+ module Utils
90
+ CAMELIZE_SPECIAL = {
91
+ 'oauth' => 'OAuth',
92
+ 'oauth2' => 'OAuth2',
93
+ 'openid' => 'OpenID',
94
+ 'open_id' => 'OpenID',
95
+ 'github' => 'GitHub',
96
+ 'tripit' => 'TripIt',
97
+ 'soundcloud' => 'SoundCloud',
98
+ 'smugmug' => 'SmugMug',
99
+ 'cas' => 'CAS',
100
+ 'trademe' => 'TradeMe',
101
+ 'ldap' => 'LDAP'
102
+ }
103
+
104
+ module_function
105
+
106
+ def form_css
107
+ "<style type='text/css'>#{OmniAuth.config.form_css}</style>"
108
+ end
109
+
110
+ def deep_merge(hash, other_hash)
111
+ target = hash.dup
112
+
113
+ other_hash.keys.each do |key|
114
+ if other_hash[key].is_a? ::Hash and hash[key].is_a? ::Hash
115
+ target[key] = deep_merge(target[key],other_hash[key])
116
+ next
117
+ end
118
+
119
+ target[key] = other_hash[key]
120
+ end
121
+
122
+ target
123
+ end
124
+
125
+ def camelize(word, first_letter_in_uppercase = true)
126
+ return CAMELIZE_SPECIAL[word.to_s] if CAMELIZE_SPECIAL[word.to_s]
127
+
128
+ if first_letter_in_uppercase
129
+ word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
130
+ else
131
+ word.first + camelize(word)[1..-1]
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,184 @@
1
+ require 'omniauth/core'
2
+
3
+ module OmniAuth
4
+ class Form
5
+ DEFAULT_CSS = <<-CSS
6
+ body {
7
+ background: #ccc;
8
+ font-family: "Lucida Grande", "Lucida Sans", Helvetica, Arial, sans-serif;
9
+ }
10
+
11
+ h1 {
12
+ text-align: center;
13
+ margin: 30px auto 0px;
14
+ font-size: 18px;
15
+ padding: 10px 10px 15px;
16
+ background: #555;
17
+ color: white;
18
+ width: 320px;
19
+ border: 10px solid #444;
20
+ border-bottom: 0;
21
+ -moz-border-radius-topleft: 10px;
22
+ -moz-border-radius-topright: 10px;
23
+ -webkit-border-top-left-radius: 10px;
24
+ -webkit-border-top-right-radius: 10px;
25
+ border-top-left-radius: 10px;
26
+ border-top-right-radius: 10px;
27
+ }
28
+
29
+ h1, form {
30
+ -moz-box-shadow: 2px 2px 7px rgba(0,0,0,0.3);
31
+ -webkit-box-shadow: 2px 2px 7px rgba(0,0,0,0.3);
32
+ }
33
+
34
+ form {
35
+ background: white;
36
+ border: 10px solid #eee;
37
+ border-top: 0;
38
+ padding: 20px;
39
+ margin: 0px auto 40px;
40
+ width: 300px;
41
+ -moz-border-radius-bottomleft: 10px;
42
+ -moz-border-radius-bottomright: 10px;
43
+ -webkit-border-bottom-left-radius: 10px;
44
+ -webkit-border-bottom-right-radius: 10px;
45
+ border-bottom-left-radius: 10px;
46
+ border-bottom-right-radius: 10px;
47
+ }
48
+
49
+ label {
50
+ display: block;
51
+ font-weight: bold;
52
+ margin-bottom: 5px;
53
+ }
54
+
55
+ input {
56
+ font-size: 18px;
57
+ padding: 4px 8px;
58
+ display: block;
59
+ margin-bottom: 10px;
60
+ width: 280px;
61
+ }
62
+
63
+ input#identifier, input#openid_url {
64
+ background: url(http://openid.net/login-bg.gif) no-repeat;
65
+ background-position: 0 50%;
66
+ padding-left: 18px;
67
+ }
68
+
69
+ button {
70
+ font-size: 22px;
71
+ padding: 4px 8px;
72
+ display: block;
73
+ margin: 20px auto 0;
74
+ }
75
+
76
+ fieldset {
77
+ border: 1px solid #ccc;
78
+ border-left: 0;
79
+ border-right: 0;
80
+ padding: 10px 0;
81
+ }
82
+
83
+ fieldset input {
84
+ width: 260px;
85
+ font-size: 16px;
86
+ }
87
+ CSS
88
+
89
+ attr_accessor :options
90
+
91
+ def initialize(options = {})
92
+ options[:title] ||= "Authentication Info Required"
93
+ self.options = options
94
+
95
+ @html = ""
96
+ header(options[:title])
97
+ end
98
+
99
+ def self.build(title=nil, &block)
100
+ form = OmniAuth::Form.new(title)
101
+ form.instance_eval(&block)
102
+ end
103
+
104
+ def label_field(text, target)
105
+ @html << "\n<label for='#{target}'>#{text}:</label>"
106
+ self
107
+ end
108
+
109
+ def input_field(type, name)
110
+ @html << "\n<input type='#{type}' id='#{name}' name='#{name}'/>"
111
+ self
112
+ end
113
+
114
+ def text_field(label, name)
115
+ label_field(label, name)
116
+ input_field('text', name)
117
+ self
118
+ end
119
+
120
+ def password_field(label, name)
121
+ label_field(label, name)
122
+ input_field('password', name)
123
+ self
124
+ end
125
+
126
+ def button(text)
127
+ @html << "\n<button type='submit'>#{text}</button>"
128
+ end
129
+
130
+ def html(html)
131
+ @html << html
132
+ end
133
+
134
+ def fieldset(legend, options = {}, &block)
135
+ @html << "\n<fieldset#{" style='#{options[:style]}'" if options[:style]}#{" id='#{options[:id]}'" if options[:id]}>\n <legend>#{legend}</legend>\n"
136
+ self.instance_eval &block
137
+ @html << "\n</fieldset>"
138
+ self
139
+ end
140
+
141
+ def header(title)
142
+ @html << <<-HTML
143
+ <!DOCTYPE html>
144
+ <html>
145
+ <head>
146
+ <title>#{title}</title>
147
+ #{css}
148
+ </head>
149
+ <body>
150
+ <h1>#{title}</h1>
151
+ <form method='post' #{"action='#{options[:url]}' " if options[:url]}noValidate='noValidate'>
152
+ HTML
153
+ self
154
+ end
155
+
156
+ def footer
157
+ return self if @footer
158
+ @html << <<-HTML
159
+ <button type='submit'>Connect</button>
160
+ </form>
161
+ </body>
162
+ </html>
163
+ HTML
164
+ @footer = true
165
+ self
166
+ end
167
+
168
+ def to_html
169
+ footer
170
+ @html
171
+ end
172
+
173
+ def to_response
174
+ footer
175
+ Rack::Response.new(@html).finish
176
+ end
177
+
178
+ protected
179
+
180
+ def css
181
+ "\n<style type='text/css'>#{OmniAuth.config.form_css}</style>"
182
+ end
183
+ end
184
+ end