|
Rails Auth with http and msql |
|
|
So I am running a RHEL5 server and I have a few Ruby on Rails Apps that I want to protect with http auth in apache but be able to manage the users and passwords with mysql (and within rails). So I found the mod_auth_mysql
> yum install mod_auth_mysql
Then I added the module to http.conf at the end of the LoadModules
LoadModule mysql_auth_module modules/mod_auth_mysql.so
Following this I reloaded apache /etc/init.d/httpd reload
Next I need to make my model in rails, I go to my rails root
> script/generate model user name:string password:string group_id:integer
then rake db:migrate to update the mysql database.
Next I get my db username and password from config/database.yml and use that to setup my .htaccess file >vim public/.htaccess I add these lines to the htaccess file
####Rails mysql auth with http AuthName "Please Login" AuthType Basic AuthMySQLHost localhost AuthMYSQLEnable on AuthMySQLDB DBNAME AuthMySQLUserTable users AuthMySQLUser MYSQLDbUSER AuthMySQLPassword MYSQLDBPass AuthMySQLNameField name AuthMySQLPasswordField password #AuthMySQLAuthoritative On require valid-user
Then I open script/console, and I had to crypt the password > script/console
u = User.new() u.name=username u.password = "pwd".crypt("pwd") u.save
Since I am running rails through Apache/Mongrel I just go to my rails public directory http://rails.jibwa.com And I type in my user and pas and I'm in.
So now I need to setup rails for http auth
This tends to get more difficult because the way you configure for mongrel is different then the way it is supposed to be configured for apache/mongrel. I ended up with too many problems and just wrote my own flex frontend and a rails data model to handle it. If anyone is interested in how to do that let me know!
|
|
Under Construction
Jibwa.com is under construction. Watch out for broken links, missing pages, potholes and bulldozers. We apologize for the temporary inconvenience - Jibwa.com Staff
News and Updates
Doran Photographic Works
A local Tucson photographer was looking for the best way of displaying and selling his photography on the web. We ended up finding the best solution w...
Read More ...
Boyd Energy Site
A energy engineer wanted a place to share his knowledge of energy conservation and other building type technologies. Using Joomla 1.5 we have a site u...
Read More ...
Restart Cable Modem and Router
If you have a modem (Cable, DSL, T1, Other), and a router you are probably familiar with the power cycle! The power cycle is three simple steps and ...
Read More ...
Lecture Audio Clip Player
Mark Pirtle Website Russell Public was interested in having Mark's audio samples playable for visitors of the website. In order to do this we had to ...
Read More ...
|