-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
70 lines (44 loc) · 2.79 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rmdprotectr
<!-- badges: start -->
<!-- badges: end -->
The goal of `rmdprotectr` is to password protect Rmarkdown HTML documents.
> This package implements **very simple** password protection for static pages or whole websites with no server configuration required: you can use Dropbox, Amazon S3 or any generic hosting service to host a private, password protected site.
## Installation
You can install the development version of rmdprotectr from [GitHub](https://github.com/favstats/rmdprotectr) with:
```{r, eval = F}
## you need to specify the main branch
remotes::install_github("favstats/rmdprotectr", ref = "main")
```
## How to Use
```{r example, eval = F}
library(rmdprotectr)
## provide a path to your .Rmd and it will be rendered in the correct folder
protect_rmd("test.Rmd", pw = "somefancypw")
## make sure your Rmd is set to knit to HTML!
```
You are set! Push to private GitHub repo and [activate GitHub pages](https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/creating-a-github-pages-site#creating-your-site) or use whatever hosting service you prefer!
You can also use this set up with any other HTML. Just put an `index.html` that you want to host into the folder generated by `protect_rmd`.
## Example
Check this [repo](https://favstats.github.io/pwtest/) for an example implementation.
You can also test the password protection by going to this [GitHub pages site](https://favstats.github.io/pwtest/). The password is: `password`.
## Things to consider
- If your hosting service offers directory listing, a visitor can bypass the protection.
- there's no protection against brute force attack. Pick a very long and hard to guess password.
- Pasting the link directly to someone will bypass the login
## Other ways to password protect your Rmd
If you are looking for a more secure encryption method for your Rmarkdowns you may want to take a look at [{encryptRmd}](https://github.com/dirkschumacher/encryptedRmd/).
You can also check out this [StackOverflow question](https://stackoverflow.com/questions/61379250/bookdown-password-protect-a-single-page-chapter-in-html) for an interesting solution that works with Rmarkdown parameters. You can also probably expand this to work with query parameters which is at least as secure as the solution presented here (not a whole lot).
## Credit
Credit to [matteobrusa](https://github.com/matteobrusa/Password-protection-for-static-pages) and [scottishstoater](https://github.com/scottishstoater/protected-github-pages) for coding most of the custom HTML required for this to work.