Password protected folders

Password protecting a folder/route

You can now protect a folder or directory with passwords.

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, redeploy your onedrive-vercel-index in Vercel so your website picks up the newest protected folder configs.

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.

What to write inside .password

Caveats

Yes, all seemingly secure protections come at a cost.

  1. The direct link of the files under your protected directory can be shared with the URL parameter &odpt=<hashed_token>, if you really want to:

    https://drive.swo.moe/api/raw/?path=/🌞%20Private%20folder/u-need-a-password/watch%20this.mp4&odpt=c8ebdc273d673d167c238dd25a997bdf9b4ecbf589452697c1a6cb416b2ed11d
    

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

  2. 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.