HTTP Authentication in OS X is broken for RESTful Rails

Thijs van der Vossen, 30 Oct 2006, 08:47 in ruby on rails and broken, last updated 28 Mar 2007, 23:42 (edit).

From the Mac OS X Leopard Technology Overview:

Leopard Server features a built-in installation of the powerful and productive Ruby on Rails web application framework. Ruby on Rails is a full stack framework optimized for sustainable productivity. Leopard Server will ship with Mongrel for simplified development and deployment of web-based applications.

That’s great. I only hope this bug will be fixed too. It would be somewhat ironic if you can’t use HTTP Basic Authentication in Safari with the new RESTful Ruby on Rails urls.

If you have access to the latest pre-release version of Mac OS X Leopard, please visit http://onautopilot.com/test;webkit and let us know if you get asked for a username and password or if it’s still broken.

Update: Tim found that you can make this work by url-escaping the semicolon. Add the following to your ApplicationController in app/controllers/application.rb:

# make HTTP Authentication work on Safari for RESTful Rails
def url_for(options = {}, *parameters_for_method_reference)
  result = super(options, parameters_for_method_reference)
  if request.env['HTTP_USER_AGENT'].to_s.include? 'AppleWebKit' 
    result.is_a?(String) ? result.gsub(';', '%3B') : result
  else
    result
  end
end

Comments

  1. Mark 24 days later: (delete)

    Leopard client seed 9A303
    Broken :-(

  2. Tim Lucas 30 days later: (delete | show email)

    I've updated my article with new code if you wanna give it a spin.

  3. Brandon Martinez 253 days later: (delete | show email)

    I heard that in the next major release of rails they are going to drop the semi-colon in preference to the slash anyway (so it'll be blogs/1/edit instead of blogs/1;edit). So, by then it shouldn't matter.

  4. Manfred Stienstra 253 days later: (delete)

    Yes, Brandon, on edge and > 1.2.3 the ; will be gone again.

Add your comment

In order to fight spam on this blog, posting comments from a browser without javascript is currently not supported.