Topic: Per-user database login
Is there any way to get RoR to establish a separate database connection for each logged-in user, or for each page request? This is unconventional, I know, but is necessitated by the following.
(1) the database already exists and has been in use for some time. Because the database is accessed through several different mechanisms (e.g. Windows applications) much of the business logic has been implemented in the database as triggers and stored procedures. (The database is Oracle.)
(2) the data is highly sensitive (medical records), so the database implements per-user security (i.e. certain individuals can see certain tables, etc) and keeps a detailed audit of activity, including the user ID for every data access
(3) this is not a public site: only a few dozen people will have login rights. We can manage that many accounts on the database, and the server load is very light.
For these reasons, Oracle needs to know the ID of every user, regardless of whether they came in via RoR or any other application. The usual arrangement (a generic "web-user" account with its credentials stored in config/database.yml) won't work. Any ideas, anyone?