Live data from Hacker News

Password protect a static HTML page

github.com

241–250 of 294 posts

Re: Password protect a static HTML page

#241
post #2

For anyone else wondering what the KDF is, it appears to be PBKDF2 with 1000 iterations: https://github.com/robinmoisson/staticrypt/blob/5dac008ba644...

There was some recent discussion about KDF for password managers. Bitwarden increased rounds from 100k to 600k for new accounts. But keep in mind, in order to get the encrypted store you either need to authenticate online or steal it from a device that previously authenticated. An attacker needs to bruteforce the master password quickly as the stored password are useless if they are changed. There's layers of security and a limited window of opportunity.

Here, the encrypted document is encouraged to be hosted publicly. There isn't any authentication before the encrypted document is downloaded. If the document remains sensitive long term, then we need to protect it from attack using computers that will exist >10 years from now.

Since this tool doesn't have layered security, and the contents likely remain sensitive long term the single security layer should be stronger.

We can hand wave this and say that the user should pick a strong password or only store minimally sensitive documents but most won't and there's nothing here to inform or encourage them to do so. (Even single character passwords are allowed...)

Re: Password protect a static HTML page

#243
If this can be repurposed to just password protect a specific section of a page, then can it be repurposed to decrypt JavaScript embedded/encrypted in that section performs an "authenticated" API calls.

This could be useful if you want to allow making edits and publishing this to a server, but keep authentication entirely client-side.

Re: Password protect a static HTML page

#244
post #227

Does anyone know a 'simple enough' way of placing a static site behind an auth wall (say, oAuth)? Just today I wrote down about what I use https://chanux.me/blog/post/static-site-with-auth/ I note down two other possible methods in the post. Would love to hear about more info.

Azure App Service provides an integrated optional auth wall for the apps deployed, without adding extra code. It may be a bit overkill to deploy a static site on the App Service, but it's supported. See here: https://learn.microsoft.com/en-us/azure/app-service/overview...

Re: Password protect a static HTML page

#245

Gad! I have spent all morning trying to --- password protect a static html page. How in the hell does HN have a story about the exact topic I've been struggling with appear just a dozen or so hours after I started working on it. Wow. I was _extremely_ happy to see this posted. However when I click the link I am taken to the library I had initially tried and had to reject. Without getting into the crypto side of thing…

> I have spent all morning trying to --- password protect a static html page

Curious. Can you say more about your use case, even if only in general terms?

Re: Password protect a static HTML page

#247
post #5

Anyone remembers .htaccess files from Apache? Good times.

Those would be quite nice, if web browsers were good HTTP clients. The user experience with basic auth is not so good. The dialogs give little way to customize and providing information for user. No support for logout or any form of password changes.

> The user experience with basic auth is not so good.

Apache actually also has an OpenID Connect module (it's certified and everything), which you can enable to have it work as a relying party: https://github.com/zmartzone/mod_auth_openidc

Basically, the actual UI will be handled by another system that you might be using, for example, in my case that might be a self-hosted Keycloak instance: https://www.keycloak.org/

I'd say that Keycloak is a pretty good solution in general, because it does some of the heavy lifting for you, maybe its shorter release cycle not being the best thing ever, though. I think IdentityServer also tried to fill this niche, but they went full on commercial recently, without OSS offerings.

As a sidenote, I also use mTLS for some personal resources and basicauth is still wonderfully easy to setup without a single point of failure for handling the authentication. A caveat might be that in practice people who try to use mTLS for app development shoot themselves in the foot, because that doesn't play nicely with reverse proxies etc.

Oh and also, to reduce needless disk IO, using a single config file approach as opposed to .htaccess can make Apache a bit more performant and easier to reason about: https://httpd.apache.org/docs/current/mod/core.html#allowove...

Re: Password protect a static HTML page

#248
Hi HN! Author of the tool here. Just woke up to a few emails pointing me to this thread. Thanks for the interest and added eyeballs!

I'll answer some of the comments here and address the newly opened issues during the day. To answer a few questions that seem common skimming this thread:

* CBC vs GCM: we had a conversation regarding this topic where it seemed CBC weaknesses do not apply in StatiCrypt context. I'd love to hear your thoughts if you have any - issue is here[1].

* WebCrypto: I've been wanting to use WebCrypto instead of crypto-js for years now. It's been in my "Important but not urgent" bucket (since crypto-js should be secure too), the interface is different so I want to make sure I do it correctly and life happened, so I never got farther than drafts. Thank you for the PRs, I hope to get to it soon!

* "static" means no server-side logic (not no JS): I first made StatiCrypt to solve my own issue of wanting to password protect an html page I could host on a static file host (Netlify, Github pages...). The whole point is to not have a server or DB, so we can't use Basic auth etc.

* Iteration count for PBKDF2: will increase today

As I write in the FAQ[2] I do my best to implement things correctly but I'm not a cryptographer - any feedback to make the tool better or more secure is very welcome!

[1] https://github.com/robinmoisson/staticrypt/issues/19#issueco...

[2] https://github.com/robinmoisson/staticrypt#is-it-secure

Re: Password protect a static HTML page

#249

I'm not a cryptographer, but I'm pretty sure that CBC ( https://github.com/robinmoisson/staticrypt/blob/main/lib/cry... ) should be replaced with GCM ( https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypt... ) since this is not a stream. https://security.stackexchange.com/questions/184305/why-woul... (also, use the built-in WebCrypto API instead of the crypto-js package)

Thanks for the feedback! We had an issue opened around that topic where it seems to me that the weak points of CBC do not apply in the context of StatiCrypt. If you have more thoughts on this I'd love to hear them.

Relevant comment here: https://github.com/robinmoisson/staticrypt/issues/19#issueco...

Re: Password protect a static HTML page

#250

I'm going to plug my project PageCrypt here too, which predates StatiCrypt, has a web UI that's good for one-off page encryption, and does use the WebCrypto API. https://github.com/MaxLaumeister/pagecrypt https://www.maxlaumeister.com/pagecrypt/

Yep, looks great! If I had known about it at the time I might not have written StatiCrypt. I added it to the "Alternatives to StatiCrypt"[1] section of the Readme years ago when I discovered it :)

[1] https://github.com/robinmoisson/staticrypt#alternatives-to-s...

Post reply on HN