User-level database connections (MySQL)


#1

Is there a way to have a user connect as themselves from Rails to MySQL,
instead of connecting via the normal database.yml user? I’m trying to
build in security at the database level, with Rails security on top.

Thanks


#2

Blake M. wrote:

Is there a way to have a user connect as themselves from Rails to MySQL,
instead of connecting via the normal database.yml user? I’m trying to
build in security at the database level, with Rails security on top.

Thanks

You want to allow different users connect to different database through
a site?

Is that what you want?

Specific the security information through the site and not through the
database.xml ?

If so you should try to look at establish_connection() method :smiley:


#3

Jamal S. wrote:

You want to allow different users connect to different database through
a site?
No, different users, same database

Specific the security information through the site and not through the
database.xml ?
Yes

If so you should try to look at establish_connection() method :smiley:
I looked into this as an option, but I have a hunch that an ActiveRecord
session (established through establish_connection) is process or
application server wide, so it couldn’t be used unless each user had
their own process.

What I’m trying to do is create a connection to the database as a user
(each user will have their own MySQL login that is generated from the
website when they register). This way we can enforce create, read,
update on specific tables priviledges at the database level, and can log
changes “in their name”.