Search code examples
rshinyshinyproxy

Is it possible to pass Login username details of shinyproxy to shiny app?


Can the login details be passed from shinyproxy to shiny app?
I want to write sql query to filter content and display the data that pertains to that user alone.


Solution

  • This is perfectly possible. As the configuration page of the manual mentions, when a user is authenticated, the following environment variables will be available in any Shiny application launched by the user:

    • SHINYPROXY_USERNAME: the name of the user, as used when logging in
    • SHINYPROXY_USERGROUPS: the groups the authenticated user is a member of, as a comma-separated value

    From within the Shiny app, you can then query this information using

    userName <- Sys.getenv("SHINYPROXY_USERNAME")
    

    and use that downstream in your SQL queries.