Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify Heroku user account in running Rails console

Is it possible to identify the heroku username of the current user connected to an app through a running console?

So say I connect to a rails console on my heroku app using

heroku run rails c --app my-app

I'd like to be able to run a command and have it print out:

[email protected]

Where [email protected] is the email / username of the user who connected to the console.

I tried a couple basic linux commands like

`whoami`

but you get a generic username like u12345

The goal is to instrument certain fields in our app with audit trails so that we can track when and who accessed sensitive information, as well as how they accessed it (CLI, through the Web UI, etc.)

like image 683
JoshReedSchramm Avatar asked Oct 21 '17 14:10

JoshReedSchramm


1 Answers

I just asked heroku this same question via a support ticket, and they do not currently support this functionality. That said, you can use heroku logs to see who and when a rails console was opened.

2019-04-12T15:48:05.727693+00:00 app[api]: Starting process with command `rails console` by user [email protected]

like image 182
Julie Avatar answered Sep 21 '22 00:09

Julie