omniauth 0.2.6 → 0.3.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.
Files changed (214) hide show
  1. data/README.md +62 -34
  2. data/lib/omniauth/version.rb +2 -2
  3. metadata +59 -225
  4. data/.autotest +0 -9
  5. data/.document +0 -5
  6. data/.gemtest +0 -0
  7. data/.gitignore +0 -56
  8. data/.rspec +0 -2
  9. data/.travis.yml +0 -9
  10. data/.yardopts +0 -4
  11. data/Gemfile +0 -12
  12. data/Rakefile +0 -51
  13. data/oa-basic/.gemtest +0 -0
  14. data/oa-basic/.rspec +0 -3
  15. data/oa-basic/.yardopts +0 -4
  16. data/oa-basic/Gemfile +0 -7
  17. data/oa-basic/LICENSE +0 -19
  18. data/oa-basic/README.rdoc +0 -34
  19. data/oa-basic/Rakefile +0 -6
  20. data/oa-basic/lib/oa-basic.rb +0 -1
  21. data/oa-basic/lib/omniauth/basic.rb +0 -8
  22. data/oa-basic/lib/omniauth/strategies/http_basic.rb +0 -56
  23. data/oa-basic/lib/omniauth/version.rb +0 -19
  24. data/oa-basic/oa-basic.gemspec +0 -27
  25. data/oa-basic/spec/omniauth/strategies/basic_spec.rb +0 -7
  26. data/oa-basic/spec/spec_helper.rb +0 -11
  27. data/oa-core/.gemtest +0 -0
  28. data/oa-core/.rspec +0 -3
  29. data/oa-core/.yardopts +0 -4
  30. data/oa-core/Gemfile +0 -3
  31. data/oa-core/LICENSE +0 -19
  32. data/oa-core/Rakefile +0 -6
  33. data/oa-core/autotest/discover.rb +0 -1
  34. data/oa-core/lib/oa-core.rb +0 -1
  35. data/oa-core/lib/omniauth/builder.rb +0 -33
  36. data/oa-core/lib/omniauth/core.rb +0 -135
  37. data/oa-core/lib/omniauth/form.rb +0 -186
  38. data/oa-core/lib/omniauth/strategy.rb +0 -227
  39. data/oa-core/lib/omniauth/test/phony_session.rb +0 -8
  40. data/oa-core/lib/omniauth/test/strategy_macros.rb +0 -34
  41. data/oa-core/lib/omniauth/test/strategy_test_case.rb +0 -49
  42. data/oa-core/lib/omniauth/test.rb +0 -12
  43. data/oa-core/lib/omniauth/version.rb +0 -19
  44. data/oa-core/oa-core.gemspec +0 -24
  45. data/oa-core/spec/omniauth/builder_spec.rb +0 -20
  46. data/oa-core/spec/omniauth/core_spec.rb +0 -79
  47. data/oa-core/spec/omniauth/strategy_spec.rb +0 -363
  48. data/oa-core/spec/spec_helper.rb +0 -12
  49. data/oa-enterprise/.gemtest +0 -0
  50. data/oa-enterprise/.rspec +0 -3
  51. data/oa-enterprise/.yardopts +0 -4
  52. data/oa-enterprise/Gemfile +0 -7
  53. data/oa-enterprise/LICENSE +0 -19
  54. data/oa-enterprise/README.rdoc +0 -82
  55. data/oa-enterprise/Rakefile +0 -6
  56. data/oa-enterprise/lib/oa-enterprise.rb +0 -1
  57. data/oa-enterprise/lib/omniauth/enterprise.rb +0 -8
  58. data/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +0 -98
  59. data/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +0 -91
  60. data/oa-enterprise/lib/omniauth/strategies/cas.rb +0 -47
  61. data/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +0 -279
  62. data/oa-enterprise/lib/omniauth/strategies/ldap.rb +0 -111
  63. data/oa-enterprise/lib/omniauth/version.rb +0 -19
  64. data/oa-enterprise/oa-enterprise.gemspec +0 -31
  65. data/oa-enterprise/spec/fixtures/cas_failure.xml +0 -4
  66. data/oa-enterprise/spec/fixtures/cas_success.xml +0 -8
  67. data/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +0 -94
  68. data/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb +0 -41
  69. data/oa-enterprise/spec/spec_helper.rb +0 -14
  70. data/oa-more/.gemtest +0 -0
  71. data/oa-more/.rspec +0 -3
  72. data/oa-more/.yardopts +0 -4
  73. data/oa-more/Gemfile +0 -7
  74. data/oa-more/LICENSE +0 -19
  75. data/oa-more/README.rdoc +0 -22
  76. data/oa-more/Rakefile +0 -6
  77. data/oa-more/lib/oa-more.rb +0 -1
  78. data/oa-more/lib/omniauth/more.rb +0 -11
  79. data/oa-more/lib/omniauth/strategies/draugiem.rb +0 -104
  80. data/oa-more/lib/omniauth/strategies/flickr.rb +0 -86
  81. data/oa-more/lib/omniauth/strategies/ign.rb +0 -93
  82. data/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +0 -1143
  83. data/oa-more/lib/omniauth/strategies/windows_live.rb +0 -39
  84. data/oa-more/lib/omniauth/strategies/yupoo.rb +0 -67
  85. data/oa-more/lib/omniauth/version.rb +0 -19
  86. data/oa-more/oa-more.gemspec +0 -29
  87. data/oa-more/spec/omniauth/strategies/draugiem_spec.rb +0 -51
  88. data/oa-more/spec/omniauth/strategies/flickr_spec.rb +0 -7
  89. data/oa-more/spec/spec_helper.rb +0 -11
  90. data/oa-oauth/.gemtest +0 -0
  91. data/oa-oauth/.rspec +0 -3
  92. data/oa-oauth/.yardopts +0 -4
  93. data/oa-oauth/Gemfile +0 -7
  94. data/oa-oauth/LICENSE +0 -19
  95. data/oa-oauth/README.rdoc +0 -35
  96. data/oa-oauth/Rakefile +0 -6
  97. data/oa-oauth/autotest/discover.rb +0 -1
  98. data/oa-oauth/lib/oa-oauth.rb +0 -1
  99. data/oa-oauth/lib/omniauth/oauth.rb +0 -56
  100. data/oa-oauth/lib/omniauth/strategies/bitly.rb +0 -46
  101. data/oa-oauth/lib/omniauth/strategies/dailymile.rb +0 -64
  102. data/oa-oauth/lib/omniauth/strategies/doit.rb +0 -60
  103. data/oa-oauth/lib/omniauth/strategies/dopplr.rb +0 -53
  104. data/oa-oauth/lib/omniauth/strategies/douban.rb +0 -60
  105. data/oa-oauth/lib/omniauth/strategies/evernote.rb +0 -54
  106. data/oa-oauth/lib/omniauth/strategies/facebook.rb +0 -70
  107. data/oa-oauth/lib/omniauth/strategies/foursquare.rb +0 -62
  108. data/oa-oauth/lib/omniauth/strategies/github.rb +0 -50
  109. data/oa-oauth/lib/omniauth/strategies/goodreads.rb +0 -44
  110. data/oa-oauth/lib/omniauth/strategies/google.rb +0 -80
  111. data/oa-oauth/lib/omniauth/strategies/gowalla.rb +0 -72
  112. data/oa-oauth/lib/omniauth/strategies/hyves.rb +0 -67
  113. data/oa-oauth/lib/omniauth/strategies/identica.rb +0 -49
  114. data/oa-oauth/lib/omniauth/strategies/instagram.rb +0 -56
  115. data/oa-oauth/lib/omniauth/strategies/instapaper.rb +0 -40
  116. data/oa-oauth/lib/omniauth/strategies/linked_in.rb +0 -56
  117. data/oa-oauth/lib/omniauth/strategies/mailru.rb +0 -107
  118. data/oa-oauth/lib/omniauth/strategies/meetup.rb +0 -56
  119. data/oa-oauth/lib/omniauth/strategies/miso.rb +0 -41
  120. data/oa-oauth/lib/omniauth/strategies/mixi.rb +0 -59
  121. data/oa-oauth/lib/omniauth/strategies/netflix.rb +0 -65
  122. data/oa-oauth/lib/omniauth/strategies/oauth.rb +0 -83
  123. data/oa-oauth/lib/omniauth/strategies/oauth2.rb +0 -91
  124. data/oa-oauth/lib/omniauth/strategies/plurk.rb +0 -58
  125. data/oa-oauth/lib/omniauth/strategies/qzone.rb +0 -69
  126. data/oa-oauth/lib/omniauth/strategies/rdio.rb +0 -45
  127. data/oa-oauth/lib/omniauth/strategies/renren.rb +0 -87
  128. data/oa-oauth/lib/omniauth/strategies/salesforce.rb +0 -44
  129. data/oa-oauth/lib/omniauth/strategies/smug_mug.rb +0 -42
  130. data/oa-oauth/lib/omniauth/strategies/sound_cloud.rb +0 -46
  131. data/oa-oauth/lib/omniauth/strategies/t163.rb +0 -57
  132. data/oa-oauth/lib/omniauth/strategies/taobao.rb +0 -79
  133. data/oa-oauth/lib/omniauth/strategies/teambox.rb +0 -49
  134. data/oa-oauth/lib/omniauth/strategies/thirty_seven_signals.rb +0 -41
  135. data/oa-oauth/lib/omniauth/strategies/tqq.rb +0 -64
  136. data/oa-oauth/lib/omniauth/strategies/trade_me.rb +0 -45
  137. data/oa-oauth/lib/omniauth/strategies/trip_it.rb +0 -22
  138. data/oa-oauth/lib/omniauth/strategies/tsina.rb +0 -79
  139. data/oa-oauth/lib/omniauth/strategies/tsohu.rb +0 -57
  140. data/oa-oauth/lib/omniauth/strategies/tumblr.rb +0 -60
  141. data/oa-oauth/lib/omniauth/strategies/twitter.rb +0 -57
  142. data/oa-oauth/lib/omniauth/strategies/type_pad.rb +0 -76
  143. data/oa-oauth/lib/omniauth/strategies/vimeo.rb +0 -54
  144. data/oa-oauth/lib/omniauth/strategies/vkontakte.rb +0 -87
  145. data/oa-oauth/lib/omniauth/strategies/xauth.rb +0 -67
  146. data/oa-oauth/lib/omniauth/strategies/yahoo.rb +0 -55
  147. data/oa-oauth/lib/omniauth/strategies/yammer.rb +0 -43
  148. data/oa-oauth/lib/omniauth/strategies/you_tube.rb +0 -73
  149. data/oa-oauth/lib/omniauth/version.rb +0 -19
  150. data/oa-oauth/oa-oauth.gemspec +0 -32
  151. data/oa-oauth/spec/fixtures/basecamp_200.xml +0 -24
  152. data/oa-oauth/spec/fixtures/campfire_200.json +0 -10
  153. data/oa-oauth/spec/omniauth/strategies/bitly_spec.rb +0 -5
  154. data/oa-oauth/spec/omniauth/strategies/dailymile_spec.rb +0 -5
  155. data/oa-oauth/spec/omniauth/strategies/doit_spec.rb +0 -5
  156. data/oa-oauth/spec/omniauth/strategies/dopplr_spec.rb +0 -5
  157. data/oa-oauth/spec/omniauth/strategies/douban_spec.rb +0 -5
  158. data/oa-oauth/spec/omniauth/strategies/evernote_spec.rb +0 -5
  159. data/oa-oauth/spec/omniauth/strategies/facebook_spec.rb +0 -5
  160. data/oa-oauth/spec/omniauth/strategies/foursquare_spec.rb +0 -18
  161. data/oa-oauth/spec/omniauth/strategies/github_spec.rb +0 -5
  162. data/oa-oauth/spec/omniauth/strategies/goodreads_spec.rb +0 -6
  163. data/oa-oauth/spec/omniauth/strategies/google_spec.rb +0 -5
  164. data/oa-oauth/spec/omniauth/strategies/gowalla_spec.rb +0 -5
  165. data/oa-oauth/spec/omniauth/strategies/hyves_spec.rb +0 -5
  166. data/oa-oauth/spec/omniauth/strategies/identica_spec.rb +0 -5
  167. data/oa-oauth/spec/omniauth/strategies/linked_in_spec.rb +0 -5
  168. data/oa-oauth/spec/omniauth/strategies/mailru_spec.rb +0 -5
  169. data/oa-oauth/spec/omniauth/strategies/meetup_spec.rb +0 -14
  170. data/oa-oauth/spec/omniauth/strategies/miso_spec.rb +0 -5
  171. data/oa-oauth/spec/omniauth/strategies/netflix_spec.rb +0 -5
  172. data/oa-oauth/spec/omniauth/strategies/oauth2_spec.rb +0 -0
  173. data/oa-oauth/spec/omniauth/strategies/oauth_spec.rb +0 -77
  174. data/oa-oauth/spec/omniauth/strategies/plurk_spec.rb +0 -5
  175. data/oa-oauth/spec/omniauth/strategies/rdio_spec.rb +0 -5
  176. data/oa-oauth/spec/omniauth/strategies/salesforce_spec.rb +0 -5
  177. data/oa-oauth/spec/omniauth/strategies/smug_mug_spec.rb +0 -5
  178. data/oa-oauth/spec/omniauth/strategies/sound_cloud_spec.rb +0 -5
  179. data/oa-oauth/spec/omniauth/strategies/t163_spec.rb +0 -5
  180. data/oa-oauth/spec/omniauth/strategies/taobao_spec.rb +0 -5
  181. data/oa-oauth/spec/omniauth/strategies/teambox_spec.rb +0 -5
  182. data/oa-oauth/spec/omniauth/strategies/thirty_seven_signals_spec.rb +0 -5
  183. data/oa-oauth/spec/omniauth/strategies/trade_me_spec.rb +0 -5
  184. data/oa-oauth/spec/omniauth/strategies/trip_it_spec.rb +0 -5
  185. data/oa-oauth/spec/omniauth/strategies/tsina_spec.rb +0 -5
  186. data/oa-oauth/spec/omniauth/strategies/tumblr_spec.rb +0 -5
  187. data/oa-oauth/spec/omniauth/strategies/twitter_spec.rb +0 -20
  188. data/oa-oauth/spec/omniauth/strategies/type_pad_spec.rb +0 -5
  189. data/oa-oauth/spec/omniauth/strategies/vimeo_spec.rb +0 -5
  190. data/oa-oauth/spec/omniauth/strategies/vkontakte_spec.rb +0 -5
  191. data/oa-oauth/spec/omniauth/strategies/yahoo_spec.rb +0 -5
  192. data/oa-oauth/spec/omniauth/strategies/yammer_spec.rb +0 -5
  193. data/oa-oauth/spec/omniauth/strategies/you_tube_spec.rb +0 -5
  194. data/oa-oauth/spec/spec_helper.rb +0 -27
  195. data/oa-oauth/spec/support/shared_examples.rb +0 -29
  196. data/oa-openid/.gemtest +0 -0
  197. data/oa-openid/.rspec +0 -3
  198. data/oa-openid/.yardopts +0 -4
  199. data/oa-openid/Gemfile +0 -7
  200. data/oa-openid/LICENSE +0 -19
  201. data/oa-openid/README.rdoc +0 -51
  202. data/oa-openid/Rakefile +0 -6
  203. data/oa-openid/lib/oa-openid.rb +0 -1
  204. data/oa-openid/lib/omniauth/openid/gapps.rb +0 -32
  205. data/oa-openid/lib/omniauth/openid.rb +0 -60
  206. data/oa-openid/lib/omniauth/strategies/google_apps.rb +0 -23
  207. data/oa-openid/lib/omniauth/strategies/open_id.rb +0 -132
  208. data/oa-openid/lib/omniauth/strategies/steam.rb +0 -55
  209. data/oa-openid/lib/omniauth/version.rb +0 -19
  210. data/oa-openid/oa-openid.gemspec +0 -28
  211. data/oa-openid/spec/omniauth/strategies/open_id_spec.rb +0 -71
  212. data/oa-openid/spec/spec_helper.rb +0 -14
  213. data/omniauth.gemspec +0 -20
  214. data/tasks/all.rb +0 -134
@@ -1,363 +0,0 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
-
3
- class ExampleStrategy
4
- include OmniAuth::Strategy
5
- def call(env); self.call!(env) end
6
- attr_reader :last_env
7
- def request_phase
8
- @fail = fail!(options[:failure]) if options[:failure]
9
- @last_env = env
10
- return @fail if @fail
11
- raise "Request Phase"
12
- end
13
- def callback_phase
14
- @fail = fail!(options[:failure]) if options[:failure]
15
- @last_env = env
16
- return @fail if @fail
17
- raise "Callback Phase"
18
- end
19
- end
20
-
21
- def make_env(path = '/auth/test', props = {})
22
- {
23
- 'REQUEST_METHOD' => 'GET',
24
- 'PATH_INFO' => path,
25
- 'rack.session' => {},
26
- 'rack.input' => StringIO.new('test=true')
27
- }.merge(props)
28
- end
29
-
30
- describe OmniAuth::Strategy do
31
- let(:app){ lambda{|env| [404, {}, ['Awesome']]}}
32
- describe '#initialize' do
33
- context 'options extraction' do
34
- it 'should be the last argument if the last argument is a Hash' do
35
- ExampleStrategy.new(app, 'test', :abc => 123).options[:abc].should == 123
36
- end
37
-
38
- it 'should be a blank hash if none are provided' do
39
- ExampleStrategy.new(app, 'test').options.should == {}
40
- end
41
- end
42
- end
43
-
44
- describe '#full_host' do
45
- let(:strategy){ ExampleStrategy.new(app, 'test', {}) }
46
- it 'should not freak out if there is a pipe in the URL' do
47
- strategy.call!(make_env('/whatever', 'rack.url_scheme' => 'http', 'SERVER_NAME' => 'facebook.lame', 'QUERY_STRING' => 'code=asofibasf|asoidnasd', 'SCRIPT_NAME' => '', 'SERVER_PORT' => 80))
48
- lambda{ strategy.full_host }.should_not raise_error
49
- end
50
- end
51
-
52
- describe '#call' do
53
- let(:strategy){ ExampleStrategy.new(app, 'test', @options) }
54
-
55
- context 'omniauth.origin' do
56
- it 'should be set on the request phase' do
57
- lambda{ strategy.call(make_env('/auth/test', 'HTTP_REFERER' => 'http://example.com/origin')) }.should raise_error("Request Phase")
58
- strategy.last_env['rack.session']['omniauth.origin'].should == 'http://example.com/origin'
59
- end
60
-
61
- it 'should be turned into an env variable on the callback phase' do
62
- lambda{ strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => 'http://example.com/origin'})) }.should raise_error("Callback Phase")
63
- strategy.last_env['omniauth.origin'].should == 'http://example.com/origin'
64
- end
65
-
66
- it 'should set from the params if provided' do
67
- lambda{ strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'origin=/foo')) }.should raise_error('Request Phase')
68
- strategy.last_env['rack.session']['omniauth.origin'].should == '/foo'
69
- end
70
-
71
- it 'should be set on the failure env' do
72
- OmniAuth.config.should_receive(:on_failure).and_return(lambda{|env| env})
73
- @options = {:failure => :forced_fail}
74
- strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => '/awesome'}))
75
- end
76
-
77
- context "with script_name" do
78
- it 'should be set on the request phase, containing full path' do
79
- env = {'HTTP_REFERER' => 'http://example.com/sub_uri/origin', 'SCRIPT_NAME' => '/sub_uri' }
80
- lambda{ strategy.call(make_env('/auth/test', env)) }.should raise_error("Request Phase")
81
- strategy.last_env['rack.session']['omniauth.origin'].should == 'http://example.com/sub_uri/origin'
82
- end
83
-
84
- it 'should be turned into an env variable on the callback phase, containing full path' do
85
- env = {
86
- 'rack.session' => {'omniauth.origin' => 'http://example.com/sub_uri/origin'},
87
- 'SCRIPT_NAME' => '/sub_uri'
88
- }
89
-
90
- lambda{ strategy.call(make_env('/auth/test/callback', env)) }.should raise_error("Callback Phase")
91
- strategy.last_env['omniauth.origin'].should == 'http://example.com/sub_uri/origin'
92
- end
93
-
94
- end
95
- end
96
-
97
- context 'default paths' do
98
- it 'should use the default request path' do
99
- lambda{ strategy.call(make_env) }.should raise_error("Request Phase")
100
- end
101
-
102
- it 'should be case insensitive on request path' do
103
- lambda{ strategy.call(make_env('/AUTH/Test'))}.should raise_error("Request Phase")
104
- end
105
-
106
- it 'should be case insensitive on callback path' do
107
- lambda{ strategy.call(make_env('/AUTH/TeSt/CaLlBAck'))}.should raise_error("Callback Phase")
108
- end
109
-
110
- it 'should use the default callback path' do
111
- lambda{ strategy.call(make_env('/auth/test/callback')) }.should raise_error("Callback Phase")
112
- end
113
-
114
- it 'should strip trailing spaces on request' do
115
- lambda{ strategy.call(make_env('/auth/test/')) }.should raise_error("Request Phase")
116
- end
117
-
118
- it 'should strip trailing spaces on callback' do
119
- lambda{ strategy.call(make_env('/auth/test/callback/')) }.should raise_error("Callback Phase")
120
- end
121
-
122
- context 'callback_url' do
123
- it 'uses the default callback_path' do
124
- strategy.should_receive(:full_host).and_return('http://example.com')
125
-
126
- lambda{ strategy.call(make_env) }.should raise_error("Request Phase")
127
-
128
- strategy.callback_url.should == 'http://example.com/auth/test/callback'
129
- end
130
-
131
- it 'preserves the query parameters' do
132
- strategy.stub(:full_host).and_return('http://example.com')
133
- begin
134
- strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
135
- rescue RuntimeError; end
136
- strategy.callback_url.should == 'http://example.com/auth/test/callback?id=5'
137
- end
138
-
139
- it 'consider script name' do
140
- strategy.stub(:full_host).and_return('http://example.com')
141
- begin
142
- strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri'))
143
- rescue RuntimeError; end
144
- strategy.callback_url.should == 'http://example.com/sub_uri/auth/test/callback'
145
- end
146
- end
147
- end
148
-
149
- context 'pre-request call through' do
150
- subject { ExampleStrategy.new(app, 'test') }
151
- let(:app){ lambda{|env| env['omniauth.boom'] = true; [env['test.status'] || 404, {}, ['Whatev']] } }
152
- it 'should be able to modify the env on the fly before the request_phase' do
153
- lambda{ subject.call(make_env) }.should raise_error("Request Phase")
154
- subject.response.status.should == 404
155
- subject.last_env.should be_key('omniauth.boom')
156
- end
157
-
158
- it 'should call through to the app instead if a non-404 response is received' do
159
- lambda{ subject.call(make_env('/auth/test', 'test.status' => 200)) }.should_not raise_error
160
- subject.response.body.should == ['Whatev']
161
- end
162
- end
163
-
164
- context 'custom paths' do
165
- it 'should use a custom request_path if one is provided' do
166
- @options = {:request_path => '/awesome'}
167
- lambda{ strategy.call(make_env('/awesome')) }.should raise_error("Request Phase")
168
- end
169
-
170
- it 'should use a custom callback_path if one is provided' do
171
- @options = {:callback_path => '/radical'}
172
- lambda{ strategy.call(make_env('/radical')) }.should raise_error("Callback Phase")
173
- end
174
-
175
- context 'callback_url' do
176
- it 'uses a custom callback_path if one is provided' do
177
- @options = {:callback_path => '/radical'}
178
- strategy.should_receive(:full_host).and_return('http://example.com')
179
-
180
- lambda{ strategy.call(make_env('/radical')) }.should raise_error("Callback Phase")
181
-
182
- strategy.callback_url.should == 'http://example.com/radical'
183
- end
184
-
185
- it 'preserves the query parameters' do
186
- @options = {:callback_path => '/radical'}
187
- strategy.stub(:full_host).and_return('http://example.com')
188
- begin
189
- strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
190
- rescue RuntimeError; end
191
- strategy.callback_url.should == 'http://example.com/radical?id=5'
192
- end
193
- end
194
- end
195
-
196
- context 'custom prefix' do
197
- before do
198
- @options = {:path_prefix => '/wowzers'}
199
- end
200
-
201
- it 'should use a custom prefix for request' do
202
- lambda{ strategy.call(make_env('/wowzers/test')) }.should raise_error("Request Phase")
203
- end
204
-
205
- it 'should use a custom prefix for callback' do
206
- lambda{ strategy.call(make_env('/wowzers/test/callback')) }.should raise_error("Callback Phase")
207
- end
208
-
209
- context 'callback_url' do
210
- it 'uses a custom prefix' do
211
- strategy.should_receive(:full_host).and_return('http://example.com')
212
-
213
- lambda{ strategy.call(make_env('/wowzers/test')) }.should raise_error("Request Phase")
214
-
215
- strategy.callback_url.should == 'http://example.com/wowzers/test/callback'
216
- end
217
-
218
- it 'preserves the query parameters' do
219
- strategy.stub(:full_host).and_return('http://example.com')
220
- begin
221
- strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
222
- rescue RuntimeError; end
223
- strategy.callback_url.should == 'http://example.com/wowzers/test/callback?id=5'
224
- end
225
- end
226
- end
227
-
228
- context 'request method restriction' do
229
- before do
230
- OmniAuth.config.allowed_request_methods = [:post]
231
- end
232
-
233
- it 'should not allow a request method of the wrong type' do
234
- lambda{ strategy.call(make_env)}.should_not raise_error
235
- end
236
-
237
- it 'should allow a request method of the correct type' do
238
- lambda{ strategy.call(make_env('/auth/test', 'REQUEST_METHOD' => 'POST'))}.should raise_error("Request Phase")
239
- end
240
-
241
- after do
242
- OmniAuth.config.allowed_request_methods = [:get, :post]
243
- end
244
- end
245
-
246
- context 'test mode' do
247
- before do
248
- OmniAuth.config.test_mode = true
249
- end
250
-
251
- it 'should short circuit the request phase entirely' do
252
- response = strategy.call(make_env)
253
- response[0].should == 302
254
- response[1]['Location'].should == '/auth/test/callback'
255
- end
256
-
257
- it 'should be case insensitive on request path' do
258
- strategy.call(make_env('/AUTH/Test'))[0].should == 302
259
- end
260
-
261
- it 'should respect SCRIPT_NAME (a.k.a. BaseURI)' do
262
- response = strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri'))
263
- response[1]['Location'].should == '/sub_uri/auth/test/callback'
264
- end
265
-
266
- it 'should be case insensitive on callback path' do
267
- strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
268
- end
269
-
270
- it 'should not short circuit requests outside of authentication' do
271
- strategy.call(make_env('/')).should == app.call(make_env('/'))
272
- end
273
-
274
- it 'should respond with the default hash if none is set' do
275
- strategy.call make_env('/auth/test/callback')
276
- strategy.env['omniauth.auth']['uid'].should == '1234'
277
- end
278
-
279
- it 'should respond with a provider-specific hash if one is set' do
280
- OmniAuth.config.mock_auth[:test] = {
281
- 'uid' => 'abc'
282
- }
283
-
284
- strategy.call make_env('/auth/test/callback')
285
- strategy.env['omniauth.auth']['uid'].should == 'abc'
286
- end
287
-
288
- it 'should simulate login failure if mocked data is set as a symbol' do
289
- OmniAuth.config.mock_auth[:test] = :invalid_credentials
290
-
291
- strategy.call make_env('/auth/test/callback')
292
- strategy.env['omniauth.error.type'].should == :invalid_credentials
293
- end
294
-
295
- it 'should set omniauth.origin on the request phase' do
296
- strategy.call(make_env('/auth/test', 'HTTP_REFERER' => 'http://example.com/origin'))
297
- strategy.env['rack.session']['omniauth.origin'].should == 'http://example.com/origin'
298
- end
299
-
300
- it 'should set omniauth.origin from the params if provided' do
301
- strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'origin=/foo'))
302
- strategy.env['rack.session']['omniauth.origin'].should == '/foo'
303
- end
304
-
305
- it 'should turn omniauth.origin into an env variable on the callback phase' do
306
- OmniAuth.config.mock_auth[:test] = {}
307
-
308
- strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => 'http://example.com/origin'}))
309
- strategy.env['omniauth.origin'].should == 'http://example.com/origin'
310
- end
311
- end
312
-
313
- context 'custom full_host' do
314
- it 'should be the string when a string is there' do
315
- OmniAuth.config.full_host = 'my.host.com'
316
- strategy.full_host.should == 'my.host.com'
317
- end
318
-
319
- it 'should run the proc with the env when it is a proc' do
320
- OmniAuth.config.full_host = Proc.new{|env| env['HOST']}
321
- strategy.call(make_env('/auth/test', 'HOST' => 'my.host.net'))
322
- strategy.full_host.should == 'my.host.net'
323
- end
324
- end
325
- end
326
-
327
- context 'setup phase' do
328
- context 'when options[:setup] = true' do
329
- let(:strategy){ ExampleStrategy.new(app, 'test', :setup => true) }
330
- let(:app){lambda{|env| env['omniauth.strategy'].options[:awesome] = 'sauce' if env['PATH_INFO'] == '/auth/test/setup'; [404, {}, 'Awesome'] }}
331
-
332
- it 'should call through to /auth/:provider/setup' do
333
- strategy.call(make_env('/auth/test'))
334
- strategy.options[:awesome].should == 'sauce'
335
- end
336
-
337
- it 'should not call through on a non-omniauth endpoint' do
338
- strategy.call(make_env('/somewhere/else'))
339
- strategy.options[:awesome].should_not == 'sauce'
340
- end
341
- end
342
-
343
- context 'when options[:setup] is an app' do
344
- let(:setup_proc) do
345
- Proc.new do |env|
346
- env['omniauth.strategy'].options[:awesome] = 'sauce'
347
- end
348
- end
349
-
350
- let(:strategy){ ExampleStrategy.new(app, 'test', :setup => setup_proc) }
351
-
352
- it 'should not call the app on a non-omniauth endpoint' do
353
- strategy.call(make_env('/somehwere/else'))
354
- strategy.options[:awesome].should_not == 'sauce'
355
- end
356
-
357
- it 'should call the rack app' do
358
- strategy.call(make_env('/auth/test'))
359
- strategy.options[:awesome].should == 'sauce'
360
- end
361
- end
362
- end
363
- end
@@ -1,12 +0,0 @@
1
- require 'simplecov'
2
- SimpleCov.start
3
- require 'rspec'
4
- require 'rack/test'
5
- require 'omniauth/core'
6
- require 'omniauth/test'
7
-
8
- RSpec.configure do |config|
9
- config.include Rack::Test::Methods
10
- config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
11
- end
12
-
File without changes
data/oa-enterprise/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --format=nested
3
- --backtrace
@@ -1,4 +0,0 @@
1
- --markup markdown
2
- --markup-provider maruku
3
- -
4
- LICENSE
@@ -1,7 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- platforms :jruby do
4
- gem 'jruby-openssl', '~> 0.7'
5
- end
6
-
7
- gemspec
@@ -1,19 +0,0 @@
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.
@@ -1,82 +0,0 @@
1
- = OmniAuth::Enterprise
2
-
3
- OmniAuth strategies for use in your intranet.
4
-
5
- == Installation
6
-
7
- To get just enterprise functionality:
8
-
9
- gem install oa-enterprise
10
-
11
- For the full auth suite:
12
-
13
- gem install omniauth
14
-
15
- == CAS
16
-
17
- Use the CAS strategy as a middleware in your application:
18
-
19
- require 'omniauth/enterprise'
20
-
21
- use OmniAuth::Strategies::CAS, :server => 'http://cas.mycompany.com/cas'
22
-
23
- Then simply direct users to '/auth/cas' to have them sign in via your company's CAS server.
24
- See OmniAuth::Strategies::CAS::Configuration for more configuration options.
25
-
26
- == LDAP
27
-
28
- Use the LDAP strategy as a middleware in your application:
29
-
30
- require 'omniauth/enterprise'
31
- use OmniAuth::Strategies::LDAP,
32
- :title => "My LDAP",
33
- :host => '10.101.10.1',
34
- :port => 389,
35
- :method => :plain,
36
- :base => 'dc=intridea, dc=com',
37
- :uid => 'sAMAccountName',
38
- :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')}
39
- :bind_dn => 'default_bind_dn'
40
- :password => 'password'
41
-
42
- All of the listed options are required, with the exception of :name_proc, :bind_dn, and :password
43
- Allowed values of :method are: :plain, :ssl, :tls.
44
-
45
- :bind_dn and :password are used to perform the initial binding if user lookup is
46
- needed. If the user lookup returns result, the DN attribute from the result set is used
47
- to perform the final binding. This is needed only when the LDAP server requires
48
- DN to be used for binding and you may only want user to using email or username
49
- in the login form.
50
-
51
- :uid is the LDAP attribute name for the user name in the login form. typically
52
- AD would be 'sAMAccountName' or 'UserPrincipalName', while OpenLDAP is 'uid'.
53
- You can also use 'dn', if your user choose the put in the dn in the login form
54
- (but usually is too long for user to remember or know).
55
-
56
- :name_proc allows you to match the user name entered with the format of the
57
- :uid attributes. For example, value of 'sAMAccountName' in AD contains only the
58
- windows user name. If your user prefers use email to login, a name_proc as
59
- above will trim the email string down to just the windows name. In summary,
60
- :name_proc helps you to fill the gap between the authentication and user lookup
61
- process.
62
-
63
- :try_sasl and :sasl_mechanisms are optional. Use them to initialize a SASL
64
- connection to server. Allowed values are 'DIGEST-MD5' and 'GSS-SPNEGO'. If you
65
- are not familiar with these authentication methods, please just avoid them.
66
-
67
- Direct users to '/auth/ldap' to have them authenticated via your
68
- company's LDAP server.
69
-
70
- == Multiple Strategies
71
-
72
- If you're using multiple strategies together, use OmniAuth's Builder. That's
73
- what it's there for:
74
-
75
- require 'omniauth/enterprise'
76
- require 'omniauth/oauth' # for Campfire
77
- require 'openid/store/filesystem'
78
-
79
- use OmniAuth::Builder do
80
- provider :cas, :server => 'http://cas.mycompany.com/cas'
81
- provider :campfire
82
- end
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
1
- require 'omniauth/enterprise'
@@ -1,8 +0,0 @@
1
- require 'omniauth/core'
2
-
3
- module OmniAuth
4
- module Strategies
5
- autoload :CAS, 'omniauth/strategies/cas'
6
- autoload :LDAP, 'omniauth/strategies/ldap'
7
- end
8
- end
@@ -1,98 +0,0 @@
1
- require 'rack'
2
-
3
- module OmniAuth
4
- module Strategies
5
- class CAS
6
- class Configuration
7
-
8
- DEFAULT_LOGIN_URL = "%s/login"
9
-
10
- DEFAULT_SERVICE_VALIDATE_URL = "%s/serviceValidate"
11
-
12
- # @param [Hash] params configuration options
13
- # @option params [String, nil] :cas_server the CAS server root URL; probably something like
14
- # `http://cas.mycompany.com` or `http://cas.mycompany.com/cas`; optional.
15
- # @option params [String, nil] :cas_login_url (:cas_server + '/login') the URL to which to
16
- # redirect for logins; options if `:cas_server` is specified,
17
- # required otherwise.
18
- # @option params [String, nil] :cas_service_validate_url (:cas_server + '/serviceValidate') the
19
- # URL to use for validating service tickets; optional if `:cas_server` is
20
- # specified, requred otherwise.
21
- # @option params [Boolean, nil] :disable_ssl_verification disable verification for SSL cert,
22
- # helpful when you developing with a fake cert.
23
- def initialize(params)
24
- parse_params params
25
- end
26
-
27
- # Build a CAS login URL from +service+.
28
- #
29
- # @param [String] service the service (a.k.a. return-to) URL
30
- #
31
- # @return [String] a URL like `http://cas.mycompany.com/login?service=...`
32
- def login_url(service)
33
- append_service @login_url, service
34
- end
35
-
36
- # Build a service-validation URL from +service+ and +ticket+.
37
- # If +service+ has a ticket param, first remove it. URL-encode
38
- # +service+ and add it and the +ticket+ as paraemters to the
39
- # CAS serviceValidate URL.
40
- #
41
- # @param [String] service the service (a.k.a. return-to) URL
42
- # @param [String] ticket the ticket to validate
43
- #
44
- # @return [String] a URL like `http://cas.mycompany.com/serviceValidate?service=...&ticket=...`
45
- def service_validate_url(service, ticket)
46
- service = service.sub(/[?&]ticket=[^?&]+/, '')
47
- url = append_service(@service_validate_url, service)
48
- url << '&ticket=' << Rack::Utils.escape(ticket)
49
- end
50
-
51
- def disable_ssl_verification?
52
- @disable_ssl_verification
53
- end
54
-
55
- private
56
-
57
- def parse_params(params)
58
- if params[:cas_server].nil? && params[:cas_login_url].nil?
59
- raise ArgumentError.new(":cas_server or :cas_login_url MUST be provided")
60
- end
61
- @login_url = params[:cas_login_url]
62
- @login_url ||= DEFAULT_LOGIN_URL % params[:cas_server]
63
- validate_is_url 'login URL', @login_url
64
-
65
- if params[:cas_server].nil? && params[:cas_service_validate_url].nil?
66
- raise ArgumentError.new(":cas_server or :cas_service_validate_url MUST be provided")
67
- end
68
- @service_validate_url = params[:cas_service_validate_url]
69
- @service_validate_url ||= DEFAULT_SERVICE_VALIDATE_URL % params[:cas_server]
70
- validate_is_url 'service-validate URL', @service_validate_url
71
-
72
- @disable_ssl_verification = params[:disable_ssl_verification]
73
- end
74
-
75
- IS_NOT_URL_ERROR_MESSAGE = "%s is not a valid URL"
76
-
77
- def validate_is_url(name, possibly_a_url)
78
- url = URI.parse(possibly_a_url) rescue nil
79
- raise ArgumentError.new(IS_NOT_URL_ERROR_MESSAGE % name) unless url.kind_of?(URI::HTTP)
80
- end
81
-
82
- # Adds +service+ as an URL-escaped parameter to +base+.
83
- #
84
- # @param [String] base the base URL
85
- # @param [String] service the service (a.k.a. return-to) URL.
86
- #
87
- # @return [String] the new joined URL.
88
- def append_service(base, service)
89
- result = base.dup
90
- result << (result.include?('?') ? '&' : '?')
91
- result << 'service='
92
- result << Rack::Utils.escape(service)
93
- end
94
-
95
- end
96
- end
97
- end
98
- end