Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

HTTP Authentication plugin for Rails

By Peter Cooper / May 28, 2006

People who are considering Rails as a platform often ask what it's integration with tools like HTTP authentication are like, often because that's the way they're currently solving certain problems. Up till now HTTP authentication has been something you've had to implement yourself, but now there's a plugin. Install it like so:

ruby script/plugin install http://wota.jp/svn/rails/plugins/branches/stable/htpasswd

And use code like this in your controllers:

class AdminController < ApplicationController
  htpasswd :user=>"maiha", :pass=>"berryz"
  htpasswd :user=>"maiha", :pass=>"7Et1Y7tCawx32", :type=>:crypted
  htpasswd :user=>"maiha", :pass=>"berryz", :realm=>"Member Only"
  htpasswd :file=>"/usr/local/apache/passwd/.htpasswd"
end

Neat, huh? Learn more in this interesting blog post about the plugin. Congratulations to maiha for such a useful plugin.

Other Posts to Enjoy

Twitter Mentions