3

Is it possible to password protect one page of a website made using R blogdown, published using the free version of Netlify?

If not, it it possible to host a password protected RMD file on a blogdown website? I tried using the encryptedRmd package but I don't think it's meant for this..

missgwolf
  • 356
  • 1
  • 11

2 Answers2

3

I was able to add basic password protection for one page on my website using Brent Scott's pagecryptr package, which is a R-wrapper for PageCrypt. The set up is very simple thanks to the R package.

  1. Create the password protected version of the RMD file, knit it to HTML, and save it somewhere (literally anywhere, but I put it on my private repository on GitHub). We'll call this file password.html.
  2. Name the page you want to password protect in your TOML file. Mine looks like this:
[[menu.main]]
    name = "Portfolio"
    url = "/Portfolio/"

Note that you do not need to create a RMD or HTML file for this page because we'll be using pagecryptr to create it.

  1. Install pagecryptr
install.packages("drat")
drat::addRepo("brentscott93")
install.packages("pagecryptr")
library(pagecryptr)
  1. In a different R script, run pagecryptr to password protect the file:
if(interactive()){
 file <- "~/password.html"
 pagecryptr(file, "password123", out_file = "~/content/Portfolio.html")
}

Notice how pagecryptr is taking the file we want to password protect (password.html) and writing HTML for it that corresponds to the page we created in our TOML (Portfolio.html). The second argument contains the password you want to use for the website (in this example, it's password123).

Commit Portfolio.html to GitHub and you will have a password protected page on your website!

missgwolf
  • 356
  • 1
  • 11
1

It appears that what you want to do is a question for the Netlify community. Once a blogdown site is created, it is just a static site, and you can use any Netlify feature you want, I'd guess. (It appears to be possible: https://answers.netlify.com/t/password-protection-for-a-single-html-page/31117/7 )

jtbayly
  • 303
  • 1
  • 6
  • This is great, but I believe it requires a paid plan – missgwolf May 21 '22 at 02:26
  • As I said, this is a question for Netlify community. Nevertheless, "HTTP Auth is not available on the free plan," but the instructions I sent you to were for "Role-based redirects." I have no idea whether role-based redirects will work for your use case, but if you have followup questions, please find a way to ask the Netlify community. – jtbayly May 21 '22 at 17:51
  • I found a way to do it using the `pagecryptr` package. Should work with any server. – missgwolf May 22 '22 at 20:24