omniauth 0.2.6 → 0.3.0.rc3

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 (189) hide show
  1. data/README.md +62 -34
  2. data/lib/omniauth/version.rb +3 -3
  3. metadata +74 -228
  4. data/Gemfile +0 -12
  5. data/Rakefile +0 -51
  6. data/oa-basic/Gemfile +0 -7
  7. data/oa-basic/LICENSE +0 -19
  8. data/oa-basic/README.rdoc +0 -34
  9. data/oa-basic/Rakefile +0 -6
  10. data/oa-basic/lib/oa-basic.rb +0 -1
  11. data/oa-basic/lib/omniauth/basic.rb +0 -8
  12. data/oa-basic/lib/omniauth/strategies/http_basic.rb +0 -56
  13. data/oa-basic/lib/omniauth/version.rb +0 -19
  14. data/oa-basic/oa-basic.gemspec +0 -27
  15. data/oa-basic/spec/omniauth/strategies/basic_spec.rb +0 -7
  16. data/oa-basic/spec/spec_helper.rb +0 -11
  17. data/oa-core/Gemfile +0 -3
  18. data/oa-core/LICENSE +0 -19
  19. data/oa-core/Rakefile +0 -6
  20. data/oa-core/autotest/discover.rb +0 -1
  21. data/oa-core/lib/oa-core.rb +0 -1
  22. data/oa-core/lib/omniauth/builder.rb +0 -33
  23. data/oa-core/lib/omniauth/core.rb +0 -135
  24. data/oa-core/lib/omniauth/form.rb +0 -186
  25. data/oa-core/lib/omniauth/strategy.rb +0 -227
  26. data/oa-core/lib/omniauth/test.rb +0 -12
  27. data/oa-core/lib/omniauth/test/phony_session.rb +0 -8
  28. data/oa-core/lib/omniauth/test/strategy_macros.rb +0 -34
  29. data/oa-core/lib/omniauth/test/strategy_test_case.rb +0 -49
  30. data/oa-core/lib/omniauth/version.rb +0 -19
  31. data/oa-core/oa-core.gemspec +0 -24
  32. data/oa-core/spec/omniauth/builder_spec.rb +0 -20
  33. data/oa-core/spec/omniauth/core_spec.rb +0 -79
  34. data/oa-core/spec/omniauth/strategy_spec.rb +0 -363
  35. data/oa-core/spec/spec_helper.rb +0 -12
  36. data/oa-enterprise/Gemfile +0 -7
  37. data/oa-enterprise/LICENSE +0 -19
  38. data/oa-enterprise/README.rdoc +0 -82
  39. data/oa-enterprise/Rakefile +0 -6
  40. data/oa-enterprise/lib/oa-enterprise.rb +0 -1
  41. data/oa-enterprise/lib/omniauth/enterprise.rb +0 -8
  42. data/oa-enterprise/lib/omniauth/strategies/cas.rb +0 -47
  43. data/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +0 -98
  44. data/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +0 -91
  45. data/oa-enterprise/lib/omniauth/strategies/ldap.rb +0 -111
  46. data/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +0 -279
  47. data/oa-enterprise/lib/omniauth/version.rb +0 -19
  48. data/oa-enterprise/oa-enterprise.gemspec +0 -31
  49. data/oa-enterprise/spec/fixtures/cas_failure.xml +0 -4
  50. data/oa-enterprise/spec/fixtures/cas_success.xml +0 -8
  51. data/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +0 -94
  52. data/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb +0 -41
  53. data/oa-enterprise/spec/spec_helper.rb +0 -14
  54. data/oa-more/Gemfile +0 -7
  55. data/oa-more/LICENSE +0 -19
  56. data/oa-more/README.rdoc +0 -22
  57. data/oa-more/Rakefile +0 -6
  58. data/oa-more/lib/oa-more.rb +0 -1
  59. data/oa-more/lib/omniauth/more.rb +0 -11
  60. data/oa-more/lib/omniauth/strategies/draugiem.rb +0 -104
  61. data/oa-more/lib/omniauth/strategies/flickr.rb +0 -86
  62. data/oa-more/lib/omniauth/strategies/ign.rb +0 -93
  63. data/oa-more/lib/omniauth/strategies/windows_live.rb +0 -39
  64. data/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +0 -1143
  65. data/oa-more/lib/omniauth/strategies/yupoo.rb +0 -67
  66. data/oa-more/lib/omniauth/version.rb +0 -19
  67. data/oa-more/oa-more.gemspec +0 -29
  68. data/oa-more/spec/omniauth/strategies/draugiem_spec.rb +0 -51
  69. data/oa-more/spec/omniauth/strategies/flickr_spec.rb +0 -7
  70. data/oa-more/spec/spec_helper.rb +0 -11
  71. data/oa-oauth/Gemfile +0 -7
  72. data/oa-oauth/LICENSE +0 -19
  73. data/oa-oauth/README.rdoc +0 -35
  74. data/oa-oauth/Rakefile +0 -6
  75. data/oa-oauth/autotest/discover.rb +0 -1
  76. data/oa-oauth/lib/oa-oauth.rb +0 -1
  77. data/oa-oauth/lib/omniauth/oauth.rb +0 -56
  78. data/oa-oauth/lib/omniauth/strategies/bitly.rb +0 -46
  79. data/oa-oauth/lib/omniauth/strategies/dailymile.rb +0 -64
  80. data/oa-oauth/lib/omniauth/strategies/doit.rb +0 -60
  81. data/oa-oauth/lib/omniauth/strategies/dopplr.rb +0 -53
  82. data/oa-oauth/lib/omniauth/strategies/douban.rb +0 -60
  83. data/oa-oauth/lib/omniauth/strategies/evernote.rb +0 -54
  84. data/oa-oauth/lib/omniauth/strategies/facebook.rb +0 -70
  85. data/oa-oauth/lib/omniauth/strategies/foursquare.rb +0 -62
  86. data/oa-oauth/lib/omniauth/strategies/github.rb +0 -50
  87. data/oa-oauth/lib/omniauth/strategies/goodreads.rb +0 -44
  88. data/oa-oauth/lib/omniauth/strategies/google.rb +0 -80
  89. data/oa-oauth/lib/omniauth/strategies/gowalla.rb +0 -72
  90. data/oa-oauth/lib/omniauth/strategies/hyves.rb +0 -67
  91. data/oa-oauth/lib/omniauth/strategies/identica.rb +0 -49
  92. data/oa-oauth/lib/omniauth/strategies/instagram.rb +0 -56
  93. data/oa-oauth/lib/omniauth/strategies/instapaper.rb +0 -40
  94. data/oa-oauth/lib/omniauth/strategies/linked_in.rb +0 -56
  95. data/oa-oauth/lib/omniauth/strategies/mailru.rb +0 -107
  96. data/oa-oauth/lib/omniauth/strategies/meetup.rb +0 -56
  97. data/oa-oauth/lib/omniauth/strategies/miso.rb +0 -41
  98. data/oa-oauth/lib/omniauth/strategies/mixi.rb +0 -59
  99. data/oa-oauth/lib/omniauth/strategies/netflix.rb +0 -65
  100. data/oa-oauth/lib/omniauth/strategies/oauth.rb +0 -83
  101. data/oa-oauth/lib/omniauth/strategies/oauth2.rb +0 -91
  102. data/oa-oauth/lib/omniauth/strategies/plurk.rb +0 -58
  103. data/oa-oauth/lib/omniauth/strategies/qzone.rb +0 -69
  104. data/oa-oauth/lib/omniauth/strategies/rdio.rb +0 -45
  105. data/oa-oauth/lib/omniauth/strategies/renren.rb +0 -87
  106. data/oa-oauth/lib/omniauth/strategies/salesforce.rb +0 -44
  107. data/oa-oauth/lib/omniauth/strategies/smug_mug.rb +0 -42
  108. data/oa-oauth/lib/omniauth/strategies/sound_cloud.rb +0 -46
  109. data/oa-oauth/lib/omniauth/strategies/t163.rb +0 -57
  110. data/oa-oauth/lib/omniauth/strategies/taobao.rb +0 -79
  111. data/oa-oauth/lib/omniauth/strategies/teambox.rb +0 -49
  112. data/oa-oauth/lib/omniauth/strategies/thirty_seven_signals.rb +0 -41
  113. data/oa-oauth/lib/omniauth/strategies/tqq.rb +0 -64
  114. data/oa-oauth/lib/omniauth/strategies/trade_me.rb +0 -45
  115. data/oa-oauth/lib/omniauth/strategies/trip_it.rb +0 -22
  116. data/oa-oauth/lib/omniauth/strategies/tsina.rb +0 -79
  117. data/oa-oauth/lib/omniauth/strategies/tsohu.rb +0 -57
  118. data/oa-oauth/lib/omniauth/strategies/tumblr.rb +0 -60
  119. data/oa-oauth/lib/omniauth/strategies/twitter.rb +0 -57
  120. data/oa-oauth/lib/omniauth/strategies/type_pad.rb +0 -76
  121. data/oa-oauth/lib/omniauth/strategies/vimeo.rb +0 -54
  122. data/oa-oauth/lib/omniauth/strategies/vkontakte.rb +0 -87
  123. data/oa-oauth/lib/omniauth/strategies/xauth.rb +0 -67
  124. data/oa-oauth/lib/omniauth/strategies/yahoo.rb +0 -55
  125. data/oa-oauth/lib/omniauth/strategies/yammer.rb +0 -43
  126. data/oa-oauth/lib/omniauth/strategies/you_tube.rb +0 -73
  127. data/oa-oauth/lib/omniauth/version.rb +0 -19
  128. data/oa-oauth/oa-oauth.gemspec +0 -32
  129. data/oa-oauth/spec/fixtures/basecamp_200.xml +0 -24
  130. data/oa-oauth/spec/fixtures/campfire_200.json +0 -10
  131. data/oa-oauth/spec/omniauth/strategies/bitly_spec.rb +0 -5
  132. data/oa-oauth/spec/omniauth/strategies/dailymile_spec.rb +0 -5
  133. data/oa-oauth/spec/omniauth/strategies/doit_spec.rb +0 -5
  134. data/oa-oauth/spec/omniauth/strategies/dopplr_spec.rb +0 -5
  135. data/oa-oauth/spec/omniauth/strategies/douban_spec.rb +0 -5
  136. data/oa-oauth/spec/omniauth/strategies/evernote_spec.rb +0 -5
  137. data/oa-oauth/spec/omniauth/strategies/facebook_spec.rb +0 -5
  138. data/oa-oauth/spec/omniauth/strategies/foursquare_spec.rb +0 -18
  139. data/oa-oauth/spec/omniauth/strategies/github_spec.rb +0 -5
  140. data/oa-oauth/spec/omniauth/strategies/goodreads_spec.rb +0 -6
  141. data/oa-oauth/spec/omniauth/strategies/google_spec.rb +0 -5
  142. data/oa-oauth/spec/omniauth/strategies/gowalla_spec.rb +0 -5
  143. data/oa-oauth/spec/omniauth/strategies/hyves_spec.rb +0 -5
  144. data/oa-oauth/spec/omniauth/strategies/identica_spec.rb +0 -5
  145. data/oa-oauth/spec/omniauth/strategies/linked_in_spec.rb +0 -5
  146. data/oa-oauth/spec/omniauth/strategies/mailru_spec.rb +0 -5
  147. data/oa-oauth/spec/omniauth/strategies/meetup_spec.rb +0 -14
  148. data/oa-oauth/spec/omniauth/strategies/miso_spec.rb +0 -5
  149. data/oa-oauth/spec/omniauth/strategies/netflix_spec.rb +0 -5
  150. data/oa-oauth/spec/omniauth/strategies/oauth2_spec.rb +0 -0
  151. data/oa-oauth/spec/omniauth/strategies/oauth_spec.rb +0 -77
  152. data/oa-oauth/spec/omniauth/strategies/plurk_spec.rb +0 -5
  153. data/oa-oauth/spec/omniauth/strategies/rdio_spec.rb +0 -5
  154. data/oa-oauth/spec/omniauth/strategies/salesforce_spec.rb +0 -5
  155. data/oa-oauth/spec/omniauth/strategies/smug_mug_spec.rb +0 -5
  156. data/oa-oauth/spec/omniauth/strategies/sound_cloud_spec.rb +0 -5
  157. data/oa-oauth/spec/omniauth/strategies/t163_spec.rb +0 -5
  158. data/oa-oauth/spec/omniauth/strategies/taobao_spec.rb +0 -5
  159. data/oa-oauth/spec/omniauth/strategies/teambox_spec.rb +0 -5
  160. data/oa-oauth/spec/omniauth/strategies/thirty_seven_signals_spec.rb +0 -5
  161. data/oa-oauth/spec/omniauth/strategies/trade_me_spec.rb +0 -5
  162. data/oa-oauth/spec/omniauth/strategies/trip_it_spec.rb +0 -5
  163. data/oa-oauth/spec/omniauth/strategies/tsina_spec.rb +0 -5
  164. data/oa-oauth/spec/omniauth/strategies/tumblr_spec.rb +0 -5
  165. data/oa-oauth/spec/omniauth/strategies/twitter_spec.rb +0 -20
  166. data/oa-oauth/spec/omniauth/strategies/type_pad_spec.rb +0 -5
  167. data/oa-oauth/spec/omniauth/strategies/vimeo_spec.rb +0 -5
  168. data/oa-oauth/spec/omniauth/strategies/vkontakte_spec.rb +0 -5
  169. data/oa-oauth/spec/omniauth/strategies/yahoo_spec.rb +0 -5
  170. data/oa-oauth/spec/omniauth/strategies/yammer_spec.rb +0 -5
  171. data/oa-oauth/spec/omniauth/strategies/you_tube_spec.rb +0 -5
  172. data/oa-oauth/spec/spec_helper.rb +0 -27
  173. data/oa-oauth/spec/support/shared_examples.rb +0 -29
  174. data/oa-openid/Gemfile +0 -7
  175. data/oa-openid/LICENSE +0 -19
  176. data/oa-openid/README.rdoc +0 -51
  177. data/oa-openid/Rakefile +0 -6
  178. data/oa-openid/lib/oa-openid.rb +0 -1
  179. data/oa-openid/lib/omniauth/openid.rb +0 -60
  180. data/oa-openid/lib/omniauth/openid/gapps.rb +0 -32
  181. data/oa-openid/lib/omniauth/strategies/google_apps.rb +0 -23
  182. data/oa-openid/lib/omniauth/strategies/open_id.rb +0 -132
  183. data/oa-openid/lib/omniauth/strategies/steam.rb +0 -55
  184. data/oa-openid/lib/omniauth/version.rb +0 -19
  185. data/oa-openid/oa-openid.gemspec +0 -28
  186. data/oa-openid/spec/omniauth/strategies/open_id_spec.rb +0 -71
  187. data/oa-openid/spec/spec_helper.rb +0 -14
  188. data/omniauth.gemspec +0 -20
  189. data/tasks/all.rb +0 -134
@@ -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
-
@@ -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,47 +0,0 @@
1
- require 'omniauth/enterprise'
2
-
3
- module OmniAuth
4
- module Strategies
5
- class CAS
6
- include OmniAuth::Strategy
7
-
8
- autoload :Configuration, 'omniauth/strategies/cas/configuration'
9
- autoload :ServiceTicketValidator, 'omniauth/strategies/cas/service_ticket_validator'
10
-
11
- def initialize(app, options = {}, &block)
12
- super(app, options[:name] || :cas, options.dup, &block)
13
- @configuration = OmniAuth::Strategies::CAS::Configuration.new(options)
14
- end
15
-
16
- protected
17
-
18
- def request_phase
19
- [
20
- 302,
21
- {
22
- 'Location' => @configuration.login_url(callback_url),
23
- 'Content-Type' => 'text/plain'
24
- },
25
- ["You are being redirected to CAS for sign-in."]
26
- ]
27
- end
28
-
29
- def callback_phase
30
- ticket = request.params['ticket']
31
- return fail!(:no_ticket, 'No CAS Ticket') unless ticket
32
- validator = ServiceTicketValidator.new(@configuration, callback_url, ticket)
33
- @user_info = validator.user_info
34
- return fail!(:invalid_ticket, 'Invalid CAS Ticket') if @user_info.nil? || @user_info.empty?
35
- super
36
- end
37
-
38
- def auth_hash
39
- OmniAuth::Utils.deep_merge(super, {
40
- 'uid' => @user_info.delete('user'),
41
- 'extra' => @user_info
42
- })
43
- end
44
-
45
- end
46
- end
47
- 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
@@ -1,91 +0,0 @@
1
- require 'net/http'
2
- require 'net/https'
3
- require 'nokogiri'
4
-
5
- module OmniAuth
6
- module Strategies
7
- class CAS
8
- class ServiceTicketValidator
9
-
10
- VALIDATION_REQUEST_HEADERS = { 'Accept' => '*/*' }
11
-
12
- # Build a validator from a +configuration+, a
13
- # +return_to+ URL, and a +ticket+.
14
- #
15
- # @param [OmniAuth::Strategies::CAS::Configuration] configuration the CAS configuration
16
- # @param [String] return_to_url the URL of this CAS client service
17
- # @param [String] ticket the service ticket to validate
18
- def initialize(configuration, return_to_url, ticket)
19
- @configuration = configuration
20
- @uri = URI.parse(@configuration.service_validate_url(return_to_url, ticket))
21
- end
22
-
23
- # Request validation of the ticket from the CAS server's
24
- # serviceValidate (CAS 2.0) function.
25
- #
26
- # Swallows all XML parsing errors (and returns +nil+ in those cases).
27
- #
28
- # @return [Hash, nil] a user information hash if the response is valid; +nil+ otherwise.
29
- #
30
- # @raise any connection errors encountered.
31
- def user_info
32
- parse_user_info(find_authentication_success(get_service_response_body))
33
- end
34
-
35
- private
36
-
37
- # turns an `<cas:authenticationSuccess>` node into a Hash;
38
- # returns nil if given nil
39
- def parse_user_info(node)
40
- return nil if node.nil?
41
- hash = {}
42
- node.children.each do |e|
43
- unless e.kind_of?(Nokogiri::XML::Text) ||
44
- e.name == 'cas:proxies' ||
45
- e.name == 'proxies'
46
- # There are no child elements
47
- if e.element_children.count == 0
48
- hash[e.name.sub(/^cas:/, '')] = e.content
49
- elsif e.element_children.count
50
- hash[e.name.sub(/^cas:/, '')] = [] if hash[e.name.sub(/^cas:/, '')].nil?
51
- hash[e.name.sub(/^cas:/, '')].push parse_user_info e
52
- end
53
- end
54
- end
55
- hash
56
- end
57
-
58
- # finds an `<cas:authenticationSuccess>` node in
59
- # a `<cas:serviceResponse>` body if present; returns nil
60
- # if the passed body is nil or if there is no such node.
61
- def find_authentication_success(body)
62
- return nil if body.nil? || body == ''
63
- begin
64
- doc = Nokogiri::XML(body)
65
- begin
66
- doc.xpath('/cas:serviceResponse/cas:authenticationSuccess')
67
- rescue Nokogiri::XML::XPath::SyntaxError
68
- doc.xpath('/serviceResponse/authenticationSuccess')
69
- end
70
- rescue Nokogiri::XML::XPath::SyntaxError
71
- nil
72
- end
73
- end
74
-
75
- # retrieves the `<cas:serviceResponse>` XML from the CAS server
76
- def get_service_response_body
77
- result = ''
78
- http = ::Net::HTTP.new(@uri.host, @uri.port)
79
- http.use_ssl = @uri.port == 443 || @uri.instance_of?(URI::HTTPS)
80
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl? && @configuration.disable_ssl_verification?
81
- http.start do |c|
82
- response = c.get "#{@uri.path}?#{@uri.query}", VALIDATION_REQUEST_HEADERS.dup
83
- result = response.body
84
- end
85
- result
86
- end
87
-
88
- end
89
- end
90
- end
91
- end
@@ -1,111 +0,0 @@
1
- require 'omniauth/enterprise'
2
- require 'net/ldap'
3
- require 'sasl/base'
4
- require 'sasl'
5
-
6
- module OmniAuth
7
- module Strategies
8
- class LDAP
9
- include OmniAuth::Strategy
10
-
11
- autoload :Adaptor, 'omniauth/strategies/ldap/adaptor'
12
- @@config = {'name' => 'cn',
13
- 'first_name' => 'givenName',
14
- 'last_name' => 'sn',
15
- 'email' => ['mail', "email", 'userPrincipalName'],
16
- 'phone' => ['telephoneNumber', 'homePhone', 'facsimileTelephoneNumber'],
17
- 'mobile_number' => ['mobile', 'mobileTelephoneNumber'],
18
- 'nickname' => ['uid', 'userid', 'sAMAccountName'],
19
- 'title' => 'title',
20
- 'location' => {"%0, %1, %2, %3 %4" => [['address', 'postalAddress', 'homePostalAddress', 'street', 'streetAddress'], ['l'], ['st'],['co'],['postOfficeBox']]},
21
- 'uid' => 'dn',
22
- 'url' => ['wwwhomepage'],
23
- 'image' => 'jpegPhoto',
24
- 'description' => 'description'}
25
-
26
- # Initialize the LDAP Middleware
27
- #
28
- # @param [Rack Application] app Standard Rack middleware argument.
29
- # @option options [String, 'LDAP Authentication'] :title A title for the authentication form.
30
- def initialize(app, options = {}, &block)
31
- super(app, options[:name] || :ldap, options.dup, &block)
32
- @name_proc = (@options.delete(:name_proc) || Proc.new {|name| name})
33
- @adaptor = OmniAuth::Strategies::LDAP::Adaptor.new(options)
34
- end
35
-
36
- protected
37
-
38
- def request_phase
39
- if env['REQUEST_METHOD'] == 'GET'
40
- get_credentials
41
- else
42
- session['omniauth.ldap'] = {'username' => request['username'], 'password' => request['password']}
43
- redirect callback_path
44
- end
45
- end
46
-
47
- def get_credentials
48
- OmniAuth::Form.build(:title => (options[:title] || "LDAP Authentication")) do
49
- text_field 'Login', 'username'
50
- password_field 'Password', 'password'
51
- end.to_response
52
- end
53
-
54
- def callback_phase
55
- begin
56
- creds = session['omniauth.ldap']
57
- session.delete 'omniauth.ldap'
58
- @ldap_user_info = {}
59
- begin
60
- (@adaptor.bind(:allow_anonymous => true) unless @adaptor.bound?)
61
- rescue Exception => e
62
- puts "failed to bind with the default credentials: " + e.message
63
- end
64
- @ldap_user_info = @adaptor.search(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @name_proc.call(creds['username'])),:limit => 1) if @adaptor.bound?
65
- bind_dn = creds['username']
66
- bind_dn = @ldap_user_info[:dn].to_a.first if @ldap_user_info[:dn]
67
- @adaptor.bind(:bind_dn => bind_dn, :password => creds['password'])
68
- @ldap_user_info = @adaptor.search(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @name_proc.call(creds['username'])),:limit => 1) if @ldap_user_info.empty?
69
- @user_info = self.class.map_user(@@config, @ldap_user_info)
70
-
71
- @env['omniauth.auth'] = auth_hash
72
-
73
- rescue Exception => e
74
- return fail!(:invalid_credentials, e)
75
- end
76
- call_app!
77
- end
78
-
79
- def auth_hash
80
- OmniAuth::Utils.deep_merge(super, {
81
- 'uid' => @user_info["uid"],
82
- 'user_info' => @user_info,
83
- 'extra' => @ldap_user_info
84
- })
85
- end
86
-
87
- def self.map_user(mapper, object)
88
- user = {}
89
- mapper.each do |key, value|
90
- case value
91
- when String
92
- user[key] = object[value.downcase.to_sym].to_s if object[value.downcase.to_sym]
93
- when Array
94
- value.each {|v| (user[key] = object[v.downcase.to_sym].to_s; break;) if object[v.downcase.to_sym]}
95
- when Hash
96
- value.map do |key1, value1|
97
- pattern = key1.dup
98
- value1.each_with_index do |v,i|
99
- part = '';
100
- v.each {|v1| (part = object[v1.downcase.to_sym].to_s; break;) if object[v1.downcase.to_sym]}
101
- pattern.gsub!("%#{i}",part||'')
102
- end
103
- user[key] = pattern
104
- end
105
- end
106
- end
107
- user
108
- end
109
- end
110
- end
111
- end