|
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
Flex 4 Pediatrics One
Recently Jibwa LCC published demonstration videos and a new website design for Pediatrics One Clinical Management software built on Flex Flash Builder...
Read More ...
Eclectic Flea Simple Business Site
Using hand written materials and some photos we managed to create a simple site for Tucson's artsy thrift store. The Eclectic Flea
...
Read More ...
Flash Builder 2 Release changes from beta
I am moving from (flex) Flash Builder Beta 2 to Flash Builder Release Stable and keeping notes on changes I've had to make to my code. 1.) mx names...
Read More ...
Radiology Gallery
Jibwa and Tripwirearts have built and launched a new website with Dr Benjamin Strong. radiologygallery.com for radiology continuing medical educ...
Read More ...
|