Database connection variables on Shinyapps.io

In an effort to keep db credentials completed separate from our R scripts and specifically github, the team I work on stores these things in our r profile files.

We are looking into hosting dashboards / apps on shinyapps.io and according to the docs, it would appear that this practice is not compatible. The suggestion I found in the docs is to utilize the config package. Unless I'm misunderstanding, this practice still amounts to including the un/pw values in code it would just be in a separate config file deployed to shinyapps and version controlled in github.

My questions are:

  1. Is my understanding correct?
  2. How are other users of shinyapps.io appropriately dealing with this secure information?
1 Like

I think you're on the right track here. I don't know that I can completely comment on "best practices" without a bit more reading on/exploration of the topic, but config.yml is definitely my favorite approach. Nothing says the config.yml file needs to be stored in GitHub (in many cases, it might not be for secrecy). However, it is deployed with your code bundle to shinyapps.io.

One of the really nice benefits of the config package is that it can pivot based on the environment (i.e. shinyapps.io can connect to a different database than locally or on a RStudio Connect instance by using the R_CONFIG_ACTIVE variable shinyapps, noted in the shinyapps docs here )

This is my go-to link on the topic, in case you are interested in further reading: https://db.rstudio.com/best-practices/portable-code/

After that, I would recommend a thorough perusal of the shinyapps docs. It has several tidbits in there about security, IP address permissiveness, etc.

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