Plugins - Authenticate As Remote User
Add to favoritesThis plugin provides a simple intereface to various Apache authentication systems to allow your Rails application to find out the currently logged in user. The plugin interface is similar to the Acts As Authenticated plugin, but it does no actual authentication.
Apache authentication modules set the REMOTE_USER variable to the user name that the user used to authenticate themselves. This variable is passed to CGI and FastCGI applications as is.
For proxy applications, e.g. mongrel, you need to write some nifty Rewrite rules to transfer the value of REMOTE_USER to your own variable:
RewriteEngine On
RewriteCond %{LA-U:REMOTE_USER} (.+)
RewriteRule .* - [E=RU:%1]
RequestHeader add REMOTE_USER %{RU}e
Here’s what this Rewrite-fu does:
Line 2: Use lookahead access to get REMOTE_USER set by authentication module
Line 3: Transfer the results of line 2 into an environment variable called RU
Line 4: Set a Request header to the environment variable from line 3.
In the proxy case, the prefix HTTP_ will be added, so the variable in your app will be HTTP_REMOTE_USER. You can override the default remote_property_name method in your code to allow for this case.
http://blog.craz8.com/authenticate-as-remote-user-plugin/
http://craz8.com/svn/trunk/plugins/authenticate_as_remote_user/
Rails' (MIT)
Security
