brontes3d-rubycas-server 0.8.0.20090812

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 (84) hide show
  1. data/CHANGELOG.txt +1 -0
  2. data/History.txt +271 -0
  3. data/LICENSE.txt +504 -0
  4. data/Manifest.txt +85 -0
  5. data/PostInstall.txt +3 -0
  6. data/README.rdoc +26 -0
  7. data/Rakefile +115 -0
  8. data/bin/rubycas-server +13 -0
  9. data/bin/rubycas-server-ctl +9 -0
  10. data/config.example.yml +551 -0
  11. data/config.ru +38 -0
  12. data/config/hoe.rb +78 -0
  13. data/config/requirements.rb +15 -0
  14. data/custom_views.example.rb +11 -0
  15. data/lib/casserver.rb +58 -0
  16. data/lib/casserver/authenticators/active_directory_ldap.rb +11 -0
  17. data/lib/casserver/authenticators/authlogic_crypto_providers/aes256.rb +43 -0
  18. data/lib/casserver/authenticators/authlogic_crypto_providers/bcrypt.rb +92 -0
  19. data/lib/casserver/authenticators/authlogic_crypto_providers/md5.rb +34 -0
  20. data/lib/casserver/authenticators/authlogic_crypto_providers/sha1.rb +35 -0
  21. data/lib/casserver/authenticators/authlogic_crypto_providers/sha512.rb +50 -0
  22. data/lib/casserver/authenticators/base.rb +48 -0
  23. data/lib/casserver/authenticators/client_certificate.rb +46 -0
  24. data/lib/casserver/authenticators/google.rb +54 -0
  25. data/lib/casserver/authenticators/ldap.rb +147 -0
  26. data/lib/casserver/authenticators/ntlm.rb +88 -0
  27. data/lib/casserver/authenticators/open_id.rb +22 -0
  28. data/lib/casserver/authenticators/sql.rb +102 -0
  29. data/lib/casserver/authenticators/sql_authlogic.rb +97 -0
  30. data/lib/casserver/authenticators/sql_encrypted.rb +77 -0
  31. data/lib/casserver/authenticators/sql_md5.rb +19 -0
  32. data/lib/casserver/authenticators/sql_rest_auth.rb +77 -0
  33. data/lib/casserver/authenticators/test.rb +19 -0
  34. data/lib/casserver/cas.rb +322 -0
  35. data/lib/casserver/conf.rb +75 -0
  36. data/lib/casserver/controllers.rb +462 -0
  37. data/lib/casserver/load_picnic.rb +19 -0
  38. data/lib/casserver/localization.rb +82 -0
  39. data/lib/casserver/models.rb +265 -0
  40. data/lib/casserver/postambles.rb +174 -0
  41. data/lib/casserver/utils.rb +30 -0
  42. data/lib/casserver/version.rb +9 -0
  43. data/lib/casserver/views.rb +245 -0
  44. data/lib/rubycas-server.rb +1 -0
  45. data/lib/rubycas-server/version.rb +1 -0
  46. data/po/de_DE/rubycas-server.po +119 -0
  47. data/po/es_ES/rubycas-server.po +115 -0
  48. data/po/fr_FR/rubycas-server.po +116 -0
  49. data/po/ja_JP/rubycas-server.po +118 -0
  50. data/po/pl_PL/rubycas-server.po +115 -0
  51. data/po/pt_BR/rubycas-server.po +115 -0
  52. data/po/ru_RU/rubycas-server.po +110 -0
  53. data/po/rubycas-server.pot +104 -0
  54. data/public/themes/cas.css +121 -0
  55. data/public/themes/notice.png +0 -0
  56. data/public/themes/ok.png +0 -0
  57. data/public/themes/simple/bg.png +0 -0
  58. data/public/themes/simple/login_box_bg.png +0 -0
  59. data/public/themes/simple/logo.png +0 -0
  60. data/public/themes/simple/theme.css +28 -0
  61. data/public/themes/urbacon/bg.png +0 -0
  62. data/public/themes/urbacon/login_box_bg.png +0 -0
  63. data/public/themes/urbacon/logo.png +0 -0
  64. data/public/themes/urbacon/theme.css +33 -0
  65. data/public/themes/warning.png +0 -0
  66. data/resources/init.d.sh +58 -0
  67. data/script/console +10 -0
  68. data/script/destroy +14 -0
  69. data/script/generate +14 -0
  70. data/script/txt2html +82 -0
  71. data/setup.rb +1585 -0
  72. data/tasks/deployment.rake +34 -0
  73. data/tasks/environment.rake +7 -0
  74. data/tasks/localization.rake +11 -0
  75. data/tasks/website.rake +17 -0
  76. data/vendor/isaac_0.9.1/LICENSE +26 -0
  77. data/vendor/isaac_0.9.1/README +78 -0
  78. data/vendor/isaac_0.9.1/TODO +3 -0
  79. data/vendor/isaac_0.9.1/VERSIONS +3 -0
  80. data/vendor/isaac_0.9.1/crypt/ISAAC.rb +171 -0
  81. data/vendor/isaac_0.9.1/isaac.gemspec +39 -0
  82. data/vendor/isaac_0.9.1/setup.rb +596 -0
  83. data/vendor/isaac_0.9.1/test/TC_ISAAC.rb +76 -0
  84. metadata +201 -0
@@ -0,0 +1,75 @@
1
+
2
+ conf_defaults = {
3
+ :maximum_unused_login_ticket_lifetime => 5.minutes,
4
+ :maximum_unused_service_ticket_lifetime => 5.minutes, # CAS Protocol Spec, sec. 3.2.1 (recommended expiry time)
5
+ :maximum_session_lifetime => 1.month, # all tickets are deleted after this period of time
6
+ :log => {:file => 'casserver.log', :level => 'DEBUG'},
7
+ :uri_path => "/"
8
+ }
9
+
10
+ if $CONF
11
+ $CONF.merge_defaults(conf_defaults)
12
+ else
13
+ unless $APP_NAME && $APP_ROOT
14
+ raise "Can't load the RubyCAS-Server configuration because $APP_NAME and/or $APP_ROOT are not defined."
15
+ end
16
+
17
+ require 'picnic/conf'
18
+ $CONF = Picnic::Conf.new(conf_defaults)
19
+ $CONF.load_from_file($APP_NAME, $APP_ROOT)
20
+ end
21
+
22
+ $AUTH = []
23
+
24
+ unless $CONF[:authenticator]
25
+ err = "
26
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
27
+
28
+ You have not yet defined an authenticator for your CAS server!
29
+ Please consult the documentation and make the necessary changes to
30
+ your config file.
31
+
32
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
33
+ "
34
+ raise Picnic::Config::Error, err
35
+ end
36
+
37
+ begin
38
+ # attempt to instantiate the authenticator
39
+ if $CONF[:authenticator].instance_of? Array
40
+ $CONF[:authenticator].each { |authenticator| $AUTH << authenticator[:class].constantize.new}
41
+ else
42
+ $AUTH << $CONF[:authenticator][:class].constantize.new
43
+ end
44
+ rescue NameError
45
+ if $CONF[:authenticator].instance_of? Array
46
+ $CONF[:authenticator].each do |authenticator|
47
+ if !authenticator[:source].nil?
48
+ # config.yml explicitly names source file
49
+ require authenticator[:source]
50
+ else
51
+ # the authenticator class hasn't yet been loaded, so lets try to load it from the casserver/authenticators directory
52
+ auth_rb = authenticator[:class].underscore.gsub('cas_server/', '')
53
+ require 'casserver/'+auth_rb
54
+ end
55
+ $AUTH << authenticator[:class].constantize.new
56
+ end
57
+ else
58
+ if $CONF[:authenticator][:source]
59
+ # config.yml explicitly names source file
60
+ require $CONF[:authenticator][:source]
61
+ else
62
+ # the authenticator class hasn't yet been loaded, so lets try to load it from the casserver/authenticators directory
63
+ auth_rb = $CONF[:authenticator][:class].underscore.gsub('cas_server/', '')
64
+ require 'casserver/'+auth_rb
65
+ end
66
+
67
+ $AUTH << $CONF[:authenticator][:class].constantize.new
68
+ end
69
+ end
70
+
71
+ $CONF[:static] = {
72
+ :urls => "/themes",
73
+ :root => "#{$APP_ROOT}/public"
74
+ }
75
+
@@ -0,0 +1,462 @@
1
+ # The #.#.# comments (e.g. "2.1.3") refer to section numbers in the CAS protocol spec
2
+ # under http://www.ja-sig.org/products/cas/overview/protocol/index.html
3
+
4
+ require 'casserver/cas'
5
+
6
+ module CASServer::Controllers
7
+
8
+ # 2.1
9
+ class Login < R '/', '/login'
10
+ include CASServer::CAS
11
+
12
+ # 2.1.1
13
+ def get
14
+ CASServer::Utils::log_controller_action(self.class, input)
15
+
16
+ # make sure there's no caching
17
+ headers['Pragma'] = 'no-cache'
18
+ headers['Cache-Control'] = 'no-store'
19
+ headers['Expires'] = (Time.now - 1.year).rfc2822
20
+
21
+ # optional params
22
+ @service = clean_service_url(input['service'])
23
+ @renew = input['renew']
24
+ @gateway = input['gateway'] == 'true' || input['gateway'] == '1'
25
+
26
+ if tgc = cookies['tgt']
27
+ tgt, tgt_error = validate_ticket_granting_ticket(tgc)
28
+ end
29
+
30
+ if tgt and !tgt_error
31
+ @message = {:type => 'notice',
32
+ :message => _("You are currently logged in as '%s'. If this is not you, please log in below.") % tgt.username }
33
+ end
34
+
35
+ if input['redirection_loop_intercepted']
36
+ @message = {:type => 'mistake',
37
+ :message => _("The client and server are unable to negotiate authentication. Please try logging in again later.")}
38
+ end
39
+
40
+ begin
41
+ if @service
42
+ if !@renew && tgt && !tgt_error
43
+ st = generate_service_ticket(@service, tgt.username, tgt)
44
+ service_with_ticket = service_uri_with_ticket(@service, st)
45
+ $LOG.info("User '#{tgt.username}' authenticated based on ticket granting cookie. Redirecting to service '#{@service}'.")
46
+ return redirect(service_with_ticket, :status => 303) # response code 303 means "See Other" (see Appendix B in CAS Protocol spec)
47
+ elsif @gateway
48
+ $LOG.info("Redirecting unauthenticated gateway request to service '#{@service}'.")
49
+ return redirect(@service, :status => 303)
50
+ end
51
+ elsif @gateway
52
+ $LOG.error("This is a gateway request but no service parameter was given!")
53
+ @message = {:type => 'mistake',
54
+ :message => _("The server cannot fulfill this gateway request because no service parameter was given.")}
55
+ end
56
+ rescue URI::InvalidURIError
57
+ $LOG.error("The service '#{@service}' is not a valid URI!")
58
+ @message = {:type => 'mistake',
59
+ :message => _("The target service your browser supplied appears to be invalid. Please contact your system administrator for help.")}
60
+ end
61
+
62
+ lt = generate_login_ticket
63
+
64
+ $LOG.debug("Rendering login form with lt: #{lt}, service: #{@service}, renew: #{@renew}, gateway: #{@gateway}")
65
+
66
+ @lt = lt.ticket
67
+
68
+ #$LOG.debug(env)
69
+
70
+ # If the 'onlyLoginForm' parameter is specified, we will only return the
71
+ # login form part of the page. This is useful for when you want to
72
+ # embed the login form in some external page (as an IFRAME, or otherwise).
73
+ # The optional 'submitToURI' parameter can be given to explicitly set the
74
+ # action for the form, otherwise the server will try to guess this for you.
75
+ if input.has_key? 'onlyLoginForm'
76
+ if @env['HTTP_HOST']
77
+ guessed_login_uri = "http#{@env['HTTPS'] && @env['HTTPS'] == 'on' ? 's' : ''}://#{@env['REQUEST_URI']}#{self / '/login'}"
78
+ else
79
+ guessed_login_uri = nil
80
+ end
81
+
82
+ @form_action = input['submitToURI'] || guessed_login_uri
83
+
84
+ if @form_action
85
+ render :login_form
86
+ else
87
+ @status = 500
88
+ _("Could not guess the CAS login URI. Please supply a submitToURI parameter with your request.")
89
+ end
90
+ else
91
+ render :login
92
+ end
93
+ end
94
+
95
+ # 2.2
96
+ def post
97
+ CASServer::Utils::log_controller_action(self.class, input)
98
+
99
+ # 2.2.1 (optional)
100
+ @service = clean_service_url(input['service'])
101
+
102
+ # 2.2.2 (required)
103
+ @username = input['username']
104
+ @password = input['password']
105
+ @lt = input['lt']
106
+
107
+ # Remove leading and trailing widespace from username.
108
+ @username.strip! if @username
109
+
110
+ if @username && $CONF[:downcase_username]
111
+ $LOG.debug("Converting username #{@username.inspect} to lowercase because 'downcase_username' option is enabled.")
112
+ @username.downcase!
113
+ end
114
+
115
+ if error = validate_login_ticket(@lt)
116
+ @message = {:type => 'mistake', :message => error}
117
+ # generate another login ticket to allow for re-submitting the form
118
+ @lt = generate_login_ticket.ticket
119
+ @status = 401
120
+ return render(:login)
121
+ end
122
+
123
+ # generate another login ticket to allow for re-submitting the form after a post
124
+ @lt = generate_login_ticket.ticket
125
+
126
+ if $CONF[:authenticator].instance_of? Array
127
+ $AUTH.each_index {|auth_index| $AUTH[auth_index].configure($CONF.authenticator[auth_index])}
128
+ else
129
+ $AUTH[0].configure($CONF.authenticator)
130
+ end
131
+
132
+ $LOG.debug("Logging in with username: #{@username}, lt: #{@lt}, service: #{@service}, auth: #{$AUTH}")
133
+
134
+ credentials_are_valid = false
135
+ extra_attributes = {}
136
+ successful_authenticator = nil
137
+ begin
138
+ $AUTH.each do |auth|
139
+ credentials_are_valid = auth.validate(
140
+ :username => @username,
141
+ :password => @password,
142
+ :service => @service,
143
+ :request => @env
144
+ )
145
+ if credentials_are_valid
146
+ extra_attributes.merge!(auth.extra_attributes) unless auth.extra_attributes.blank?
147
+ successful_authenticator = auth
148
+ break
149
+ end
150
+ end
151
+ rescue CASServer::AuthenticatorError => e
152
+ $LOG.error(e)
153
+ @message = {:type => 'mistake', :message => e.to_s}
154
+ return render(:login)
155
+ end
156
+
157
+ if credentials_are_valid
158
+ $LOG.info("Credentials for username '#{@username}' successfully validated using #{successful_authenticator.class.name}.")
159
+ $LOG.debug("Authenticator provided additional user attributes: #{extra_attributes.inspect}") unless extra_attributes.blank?
160
+
161
+ # 3.6 (ticket-granting cookie)
162
+ tgt = generate_ticket_granting_ticket(@username, extra_attributes)
163
+
164
+ if $CONF.maximum_session_lifetime
165
+ expires = $CONF.maximum_session_lifetime.to_i.from_now
166
+ expiry_info = " It will expire on #{expires}."
167
+ else
168
+ expiry_info = " It will not expire."
169
+ end
170
+
171
+ if $CONF.maximum_session_lifetime
172
+ cookies['tgt'] = {
173
+ :value => tgt.to_s,
174
+ :expires => Time.now + $CONF.maximum_session_lifetime
175
+ }
176
+ else
177
+ cookies['tgt'] = tgt.to_s
178
+ end
179
+
180
+ $LOG.debug("Ticket granting cookie '#{cookies['tgt'].inspect}' granted to #{@username.inspect}. #{expiry_info}")
181
+
182
+ if @service.blank?
183
+ $LOG.info("Successfully authenticated user '#{@username}' at '#{tgt.client_hostname}'. No service param was given, so we will not redirect.")
184
+ @message = {:type => 'confirmation', :message => _("You have successfully logged in.")}
185
+ else
186
+ @st = generate_service_ticket(@service, @username, tgt)
187
+ begin
188
+ service_with_ticket = service_uri_with_ticket(@service, @st)
189
+
190
+ $LOG.info("Redirecting authenticated user '#{@username}' at '#{@st.client_hostname}' to service '#{@service}'")
191
+ return redirect(service_with_ticket, :status => 303) # response code 303 means "See Other" (see Appendix B in CAS Protocol spec)
192
+ rescue URI::InvalidURIError
193
+ $LOG.error("The service '#{@service}' is not a valid URI!")
194
+ @message = {:type => 'mistake',
195
+ :message => _("The target service your browser supplied appears to be invalid. Please contact your system administrator for help.")}
196
+ end
197
+ end
198
+ else
199
+ $LOG.warn("Invalid credentials given for user '#{@username}'")
200
+ @message = {:type => 'mistake', :message => _("Incorrect username or password.")}
201
+ @status = 401
202
+ end
203
+
204
+ render :login
205
+ end
206
+ end
207
+
208
+ # 2.3
209
+ class Logout < R '/logout'
210
+ include CASServer::CAS
211
+
212
+ # 2.3.1
213
+ def get
214
+ CASServer::Utils::log_controller_action(self.class, input)
215
+
216
+ # The behaviour here is somewhat non-standard. Rather than showing just a blank
217
+ # "logout" page, we take the user back to the login page with a "you have been logged out"
218
+ # message, allowing for an opportunity to immediately log back in. This makes it
219
+ # easier for the user to log out and log in as someone else.
220
+ @service = clean_service_url(input['service'] || input['destination'])
221
+ @continue_url = input['url']
222
+
223
+ @gateway = input['gateway'] == 'true' || input['gateway'] == '1'
224
+
225
+ tgt = CASServer::Models::TicketGrantingTicket.find_by_ticket(cookies['tgt'])
226
+
227
+ cookies.delete 'tgt'
228
+
229
+ $AUTH.each do |auth|
230
+ if auth.respond_to?(:logout)
231
+ auth.logout(tgt.extra_attributes)
232
+ end
233
+ end
234
+
235
+ if tgt
236
+ CASServer::Models::TicketGrantingTicket.transaction do
237
+ $LOG.debug("Deleting Service/Proxy Tickets for '#{tgt}' for user '#{tgt.username}'")
238
+ tgt.granted_service_tickets.each do |st|
239
+ send_logout_notification_for_service_ticket(st) if $CONF.enable_single_sign_out
240
+ # TODO: Maybe we should do some special handling if send_logout_notification_for_service_ticket fails?
241
+ # (the above method returns false if the POST results in a non-200 HTTP response).
242
+ $LOG.debug "Deleting #{st.class.name.demodulize} #{st.ticket.inspect} for service #{st.service}."
243
+ st.destroy
244
+ end
245
+
246
+ pgts = CASServer::Models::ProxyGrantingTicket.find(:all,
247
+ :conditions => [CASServer::Models::Base.connection.quote_table_name(CASServer::Models::ServiceTicket.table_name)+".username = ?", tgt.username],
248
+ :include => :service_ticket)
249
+ pgts.each do |pgt|
250
+ $LOG.debug("Deleting Proxy-Granting Ticket '#{pgt}' for user '#{pgt.service_ticket.username}'")
251
+ pgt.destroy
252
+ end
253
+
254
+ $LOG.debug("Deleting #{tgt.class.name.demodulize} '#{tgt}' for user '#{tgt.username}'")
255
+ tgt.destroy
256
+ end
257
+
258
+ $LOG.info("User '#{tgt.username}' logged out.")
259
+ else
260
+ $LOG.warn("User tried to log out without a valid ticket-granting ticket.")
261
+ end
262
+
263
+ @message = {:type => 'confirmation', :message => _("You have successfully logged out.")}
264
+
265
+ @message[:message] +=_(" Please click on the following link to continue:") if @continue_url
266
+
267
+ @lt = generate_login_ticket
268
+
269
+ if @gateway && @service
270
+ redirect(@service, :status => 303)
271
+ elsif @continue_url
272
+ render :logout
273
+ else
274
+ render :login
275
+ end
276
+ end
277
+ end
278
+
279
+ # 2.4
280
+ class Validate < R '/validate'
281
+ include CASServer::CAS
282
+
283
+ # 2.4.1
284
+ def get
285
+ CASServer::Utils::log_controller_action(self.class, input)
286
+
287
+ # required
288
+ @service = clean_service_url(input['service'])
289
+ @ticket = input['ticket']
290
+ # optional
291
+ @renew = input['renew']
292
+
293
+ st, @error = validate_service_ticket(@service, @ticket)
294
+ @success = st && !@error
295
+
296
+ @username = st.username if @success
297
+
298
+ @status = CASServer::Controllers.response_status_from_error(@error) if @error
299
+
300
+ render :validate
301
+ end
302
+ end
303
+
304
+ # 2.5
305
+ class ServiceValidate < R '/serviceValidate'
306
+ include CASServer::CAS
307
+
308
+ # 2.5.1
309
+ def get
310
+ CASServer::Utils::log_controller_action(self.class, input)
311
+
312
+ # required
313
+ @service = clean_service_url(input['service'])
314
+ @ticket = input['ticket']
315
+ # optional
316
+ @pgt_url = input['pgtUrl']
317
+ @renew = input['renew']
318
+
319
+ st, @error = validate_service_ticket(@service, @ticket)
320
+ @success = st && !@error
321
+
322
+ if @success
323
+ @username = st.username
324
+ if @pgt_url
325
+ pgt = generate_proxy_granting_ticket(@pgt_url, st)
326
+ @pgtiou = pgt.iou if pgt
327
+ end
328
+ @extra_attributes = st.granted_by_tgt.extra_attributes || {}
329
+ end
330
+
331
+ @status = CASServer::Controllers.response_status_from_error(@error) if @error
332
+
333
+ render :service_validate
334
+ end
335
+ end
336
+
337
+ # 2.6
338
+ class ProxyValidate < R '/proxyValidate'
339
+ include CASServer::CAS
340
+
341
+ # 2.6.1
342
+ def get
343
+ CASServer::Utils::log_controller_action(self.class, input)
344
+
345
+ # required
346
+ @service = clean_service_url(input['service'])
347
+ @ticket = input['ticket']
348
+ # optional
349
+ @pgt_url = input['pgtUrl']
350
+ @renew = input['renew']
351
+
352
+ @proxies = []
353
+
354
+ t, @error = validate_proxy_ticket(@service, @ticket)
355
+ @success = t && !@error
356
+
357
+ @extra_attributes = {}
358
+ if @success
359
+ @username = t.username
360
+
361
+ if t.kind_of? CASServer::Models::ProxyTicket
362
+ @proxies << t.granted_by_pgt.service_ticket.service
363
+ end
364
+
365
+ if @pgt_url
366
+ pgt = generate_proxy_granting_ticket(@pgt_url, t)
367
+ @pgtiou = pgt.iou if pgt
368
+ end
369
+
370
+ @extra_attributes = t.granted_by_tgt.extra_attributes || {}
371
+ end
372
+
373
+ @status = CASServer::Controllers.response_status_from_error(@error) if @error
374
+
375
+ render :proxy_validate
376
+ end
377
+ end
378
+
379
+ class Proxy < R '/proxy'
380
+ include CASServer::CAS
381
+
382
+ # 2.7
383
+ def get
384
+ CASServer::Utils::log_controller_action(self.class, input)
385
+
386
+ # required
387
+ @ticket = input['pgt']
388
+ @target_service = input['targetService']
389
+
390
+ pgt, @error = validate_proxy_granting_ticket(@ticket)
391
+ @success = pgt && !@error
392
+
393
+ if @success
394
+ @pt = generate_proxy_ticket(@target_service, pgt)
395
+ end
396
+
397
+ @status = CASServer::Controllers.response_status_from_error(@error) if @error
398
+
399
+ render :proxy
400
+ end
401
+ end
402
+
403
+ # Controller for obtaining login tickets.
404
+ # This is useful when you want to build a custom login form located on a
405
+ # remote server. Your form will have to include a valid login ticket
406
+ # value, and this can be fetched from the CAS server using this controller'
407
+ # POST method.
408
+ class LoginTicketDispenser < R '/loginTicket'
409
+ include CASServer::CAS
410
+
411
+ def get
412
+ CASServer::Utils::log_controller_action(self.class, input)
413
+ $LOG.error("Tried to use login ticket dispenser with get method!")
414
+ @status = 422
415
+ _("To generate a login ticket, you must make a POST request.")
416
+ end
417
+
418
+ # Renders a page with a login ticket (and only the login ticket)
419
+ # in the response body.
420
+ def post
421
+ CASServer::Utils::log_controller_action(self.class, input)
422
+ lt = generate_login_ticket
423
+
424
+ $LOG.debug("Dispensing login ticket #{lt} to host #{(@env['HTTP_X_FORWARDED_FOR'] || @env['REMOTE_HOST'] || @env['REMOTE_ADDR']).inspect}")
425
+
426
+ @lt = lt.ticket
427
+
428
+ @lt
429
+ end
430
+ end
431
+
432
+ # class Themes < R '/themes/(.+)'
433
+ # MIME_TYPES = {'.css' => 'text/css', '.js' => 'text/javascript',
434
+ # '.jpg' => 'image/jpeg'}
435
+ # PATH = $CONF.themes_dir || File.expand_path(File.dirname(__FILE__))+'/../themes'
436
+ #
437
+ # def get(path)
438
+ # headers['Content-Type'] = MIME_TYPES[path[/\.\w+$/, 0]] || "text/plain"
439
+ # unless path.include? ".." # prevent directory traversal attacks
440
+ # headers['X-Sendfile'] = "#{PATH}/#{path}"
441
+ # data = File.read(headers['X-Sendfile'])
442
+ # headers['Content-Length'] = data.size.to_s # Rack Camping adapter chokes without this
443
+ # return data
444
+ # else
445
+ # status = "403"
446
+ # "403 - Invalid path"
447
+ # end
448
+ # end
449
+ # end
450
+
451
+ def response_status_from_error(error)
452
+ case error.code.to_s
453
+ when /^INVALID_/, 'BAD_PGT'
454
+ 422
455
+ when 'INTERNAL_ERROR'
456
+ 500
457
+ else
458
+ 500
459
+ end
460
+ end
461
+ module_function :response_status_from_error
462
+ end