Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server-independant password protection (javascript checksum) #457

Open
drzraf opened this issue Jan 31, 2022 · 2 comments
Open

server-independant password protection (javascript checksum) #457

drzraf opened this issue Jan 31, 2022 · 2 comments

Comments

@drzraf
Copy link

drzraf commented Jan 31, 2022

I'd like to host a password-protected gallery on a non-httpd server (a cheap public-facing object-bucket storage, OpenStack swift).

No .htaccess here but there is a good old alternative: Javascript checksums

The index.html providing a password form, whose value is checksum'ed/hashed so that we if the password is correct, we're get redirected to the random path (derived from the password, where the files are stored).

Could be md5 or a simpler checksum heuristic like this sample pseudo-code:

onSubmit() {
  let password = document.getElementById("passwd").value;
  if (md5("<salt>" + password) == "0xdeadbeef" )) {
     window.location = base64enc(password);
  } else {
     alert("failed");
  }
}

(I guess an heuristic possibly exists so that the hidden path could be preserved even if the password is changed afterwards, in order to avoid file moves/reuploads, for example by replacing base64enc(password) by aes_decrypt(password, <aes-encrypt-path>);

@dbw9580
Copy link
Contributor

dbw9580 commented Mar 24, 2022

Though not exactly the same thing, the encrypt plugin may be worth taking a look. http://sigal.saimon.org/en/latest/plugins.html#module-sigal.plugins.encrypt

@thomasdn
Copy link
Contributor

I second this. This is an elegant way to implement this stuff. Of course, if someone shares a link to such a secret image then it will be publicly viewable.

An even simpler way of implementing this is:

onSubmit() {
  let password = document.getElementById("passwd").value;
     window.location = sha256("<salt>" + password) + ".html";
}

An incorrect password would give a 404.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants