Repository navigation
Closed
Description
Staticrypt is great! I extended it a bit so that it could be used to encrypt an entire website. Here are my steps:
- Change the template so that it stores the password in localStorage once entered.
- Run staticrypt on all html files.
- Now we have a website where the user can log in once and then navigate to other pages without entering in their password for each page. (demo at https://epicfaace.github.io/ghpages-private-test/, password is "password")
@robinmoisson would you be willing to accept PRs to modify staticrypt so that it can work with these kinds of workflows more easily? Essentially, staticrypt could then work out-of-the-box to let people easily deploy a password-protected github pages website (or, really, any static website).
I'm thinking of updating the staticrypt CLI options with the following parameters:
Usage: staticrypt <filename or directory> <passphrase> [options]
Options:
--help Show help [boolean]
--version Show version number [boolean]
-e, --embed Whether or not to embed crypto-js in the page (or use an
external CDN) [boolean] [default: true]
-o, --output File name / path for generated encrypted file
[string] [default: null]
-t, --title Title for output HTML page
[string] [default: "Protected Page"]
-i, --instructions Special instructions to display to the user.
[string] [default: null]
-f, --file-template Path to custom HTML template with password prompt.
[string] [default: "[...]/cli/password_template.html"]
-i, --in-place Whether to modify input file(s) in place.
-p, --persist-type Whether to persist the password in the user's browser.
Can be set to "localStorage", "sessionStorage", or "cookie".
[string] [default: null]
Then, generating a static site and deploying it to GitHub Pages might be as easy as doing the following:
npm run build # generates files in `dist`
staticrypt dist -i -p localStorage
gh-pages -d distSome potential improvements:
- It would be good to have an option such as
--logout-urlthat allows a logout page to be generated; the user can then link to this logout page on the static site which should clear the password from the user's localStorage / cookies. - It seems okay, but not ideal, to store the plain password in the user's localStorage / cookies. Could we make the stored password automatically expire (if there's some cryptographic way to make a token valid only for a particular amount of time, that would be great -- otherwise, we could just maybe delete a cookie after a certain period of time)?
- Allowing provisioning of multiple users and passwords.
Reacted by Susan, 404invalid-user and Robin Moisson
Metadata
Metadata
Assignees
Labels
No labels
Activity
404invalid-user commentedon Aug 4, 2020
this would be nice to have because i tried folowing your steps and failed
epicfaace commentedon Aug 4, 2020
Here's a gist with the code I created for this, if it helps: https://gist.github.com/epicfaace/c1a4452401af14d35b60fe211f2c1559
404invalid-user commentedon Aug 5, 2020
Thank you I'll have a look at this an see if I can get it to work
wzdiyb commentedon Jan 23, 2021
@epicfaace Thanks for your wonderful sharing, the idea helps a lot!
robinmoisson commentedon Feb 9, 2022
Hey @epicfaace, thanks a lot for the detailed suggestion and my sincere apologies for taking so long to answer.
I think the feature is a good one. Regarding the use case, it feels to me the main one would rather be browser dependent than "choosing between localStorage and sessionStorage at encryption time": if I access the page from my personal computer I might want to stay "logged in", if not it might be better to ask the password for each page.
So that's what I implemented in #124 (along with a way to logout and expiration handling).
sessionStoragemight be an interesting future way to enable decrypting multiple different pages on a single domain without persisting the passphrase for a longer time.Regarding the storage in clear text I feel on the same page as you are (I think): it's not ideal, it might be okay-ish here.
Thinking out loud, here are some threats I think it might enable:
I don't really see a way to get the localStorage content that would not also allow reading of the page decrypted in browser (though there might be), so my assumption would be that the content of the page is compromised and what might be protected is the passphrase the user typed.
A mitigation I had in mind was salting + hashing the passphrase and store that in localStorage, so the hashed passphrase effectively becomes the key to the encrypted page. This doesn't mitigate the leaking of the hashed passphrase, which allows decryption of the page, but does mitigate password reuse.
#124 first draft has clear text passphrase storage.