Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use "database users" to authenticate in Ruby on Rails

I have a PostgreSQL database that I access from various locations, and would like to add an interface with Ruby on Rails 3. For authentication I need to login users with the same credentials used to create them directly in the database; is there a way to make Rails connect to the database each time with different username/password, based on the current user? Thanks for any hints!

like image 233
Takhion Avatar asked Nov 14 '22 07:11

Takhion


1 Answers

Yes. Use a custom authentication on devise that makes a query to the underlying postgresql database.

See:

Custom authentication strategy for devise

I would certainly add some kind of filter to reduce the list of users that can authenticate this way.

like image 137
Nicolas Modrzyk Avatar answered Dec 10 '22 06:12

Nicolas Modrzyk