Identifying current user in RStudio Connect

Hello,
Is there any statement or configuration tweak that would enable the identification of the current user of an application or a document? We tried different strategies, but they all either return "rstudio-connect" or nothing. Examples:

Sys.getenv("USER")
system("whoami")[1])
system("echo $HOME")[1])
1 Like

Hello,

I don't have a RStudio Connect on hand, but have you tried good ol' Sys.info()?
It does the job with regular server version

Sys.info()["user"]
Sys.getenv("LOGNAME") # also try this...

Hello,

Thank you for the suggestions, but they also return "rstudio-connect". I am afraid that, should a solution exist, it would require some configuration changes.

Do you use the authentication mechanism from within RStudio connect ? That is to say your app is not public and you have to log in as a user to rstudio connect to see the app.

And Have you changed the user who run the application to the identified user ?

You get Sys.getenv("USER") to `rstudio-connect because by default this the unix user that runs all the content unless you say otherwise.

With RStudio connect, you can get information for identified user in the session$user value in a shiny app. You can look at this documentation to know more
https://shiny.rstudio.com/articles/permissions.html

This will allow you to have customized application depending on who is consulting it. See some examples:

Also RStudio connect allows to change the user who runs an application. For that, the user would have to be identified on the server, and the parameter should have been change in the app setting
https://docs.rstudio.com/connect/user/settings-panel.html#set-executor

With this, the application will run on the system (on the server) using an account corresponding to another user, or the identified user directly. This is required if you have some control ressource or control access based on the linux account you want to be used by your app. Otherwise, the previous solution should be the one you are looking for to identify current user with session$user

6 Likes

session$user does work, thanks a bunch!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.