Skip to content

Features

lyc8503 edited this page Oct 17, 2023 · 3 revisions

Password protected folders

You can now protect a folder or directory with passwords.

password-demo.mp4

Method

  • Declare the protected folder's path under protectedRoutes (which is an array) in config/site.json.
  • Create a plain text file that is named .password (character for character, must be this name), and move this file under the folder that you wish to password protect.
  • Open this .password file with a text editor, like VS Code or Notepad, and save the password inside (in plain text format).
  • Finally, make sure Cloudflare have redeployed your project so your website picks up the newest protected folder configs (which should be automatic).

Details

If you are wondering what to define in protectedRoutes, here is an example.

Suppose we have the following folder structure:

.
├── 📕 Books
│   └── ...
├── 🌞 Private folder
│   ├── this-is-public
│   └── u-need-a-password   <-- this is the folder to protect
├── 🍡 Genshin PV
│   └── ...
└── README.md

We want to password protect the /u-need-a-password directory, so we would write inside protectedRoutes the absolute path to root.

"protectedRoutes": [
  "/🌞 Private folder/u-need-a-password",
],

If you want to add another route, then add it to the next item in the array.

"protectedRoutes": [
  "/🌞 Private folder/u-need-a-password",
   "/another/route/for/me/to/protect",
],

If there is no directory for you to password protect and you want to disable this function, you can simply pass an empty array [] to protectedRoutes.

"protectedRoutes": [],

If you are confused about whether you need to encrypt your password, don't. Put that plain text inside .password. Whatever you save inside .password, you are going to use as the password for entering the protected directory.

dot-password-file

Caveats

Yes, all seemingly secure protections come at a cost.

The direct link of the files under your protected directory can be shared with the URL parameter &odpt=<hashed_token> (This link can be copied via Copy direct link Button), if you really want to:

https://pan.lyc8503.site/api/raw?path=/Demo/%F0%9F%98%8EAnother%20Private%20Folder%20Password%20123/%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99.mp4&odpt=a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3

Whether or not this exposes your password, protected files, personal information, etc., is all unknown. Use at your own risk.

I personally cannot guarantee that this protection is impenetrable and fully secure. Hence, I would not recommend protecting sensitive information with this method. Think of this as an extra layer of annoyance to keep files you want to share with only the people you wish.

Clone this wiki locally