[R-bloggers] Startup with Secrets – A Poor Man’s Approach |
Startup with Secrets – A Poor Man’s Approach Posted: 29 Mar 2018 05:00 PM PDT (This article was first published on JottR on R, and kindly contributed to R-bloggers) New release: startup 0.10.0 is now on CRAN. If your R startup files (
Several R packages provide APIs for easier access to online services such as GitHub, GitLab, Twitter, Amazon AWS, Google GCE, etc. These packages often rely on R options or environment variables to hold your secret credentials or tokens in order to provide more or less automatic, batch-friendly access to those services. For convenience, it is common to set these secret options in then, when you start R, environment variable which means that also devtools can make use of it. IMPORTANT: If you're on a shared file system or a computer with multiple users, you want to make sure no one else can access your files holding "secrets". If you're on Linux or macOS, this can be done by: Also, keeping "secrets" in options or environment variables is not super secure. For instance, if your script or a third-party package dumps Having said this, with the above setup we at least know that the secret token is only loaded when we run R and only when we run R as ourselves. Starting with startup 0.10.0 (*), we can customize the startup further such that secrets are only loaded conditionally on a certain environment variable. For instance, if we instead of putting our secret files in a folder named: because then (i) that folder will not be visible to anyone else because we already restricted access to will load the secrets, but none of: In other words, with the above approach, you can avoid loading secrets by default and only load them when you really need them. This lowers the risk of exposing them by mistake in log files or to R code you're not in control of. Furthermore, if you only need and it will only be loaded in an interactive session, e.g. and To repeat what already been said above, storing secrets in environment variables or R variables provides only very limited security. The above approach is meant to provide you with a bit more control if you are already storing credentials in What's new in startup 0.10.0?
Links
(*) In startup (< 0.10.0),
To leave a comment for the author, please follow the link and comment on their blog: JottR on R. R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more... This posting includes an audio/video/photo media file: Download Now |
You are subscribed to email updates from R-bloggers. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google, 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
Comments
Post a Comment