mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-08 16:49:02 +03:00
[GH-ISSUE #277] Hashed Passwords #148
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Protinon on GitHub (Nov 3, 2023).
Original GitHub issue: https://github.com/sigoden/dufs/issues/277
Support for hashed passwords in authentication
Currently passwords can only be specified in cleartext. Storing hashes would be much more secure, especially if passwords are kept in a configuration file.
Implement Suggestion
Currently the syntax is
username:password. I suggest an implementation similar to the/etc/shadowfile used in Unix OSs:username:$type$salt$hashed$. Wheretypespecifies the algorithm (MD5/SHA-256/...),saltandhashedare combined to secure the password. Cleartext passwords could still be specified using the current syntax, so this doesn't need to break existing configuration. Hashed passwords are represented as hex, so they would not interfere with the currently used special characters:and@.An example of authentication using plaintext passwords would be
admin:admin@/:rw. That same user with an MD5 hashed password would beadmin:$1$US11Sj3d$33qmh0VIXWPcLdeELHOpC@/:rwAt a basic implementation, MD5 would be the only available algorithm.
/etc/shadowsupports many types, which probably isn't necessary for dufs. The/etc/shadowsyntax seems common, so implementing other algorithms may be trivial if a password library is used for this.This could be put in dufs documentation so users can easily generate their own hashed password: https://unix4lyfe.org/crypt/
For more reference, this explains the
/etc/shadowfile in greater detail: https://www.cyberciti.biz/faq/understanding-etcshadow-file/3Proxy implements very similar authentication: https://github.com/3proxy/3proxy/wiki/How-To-(incomplete)#USERS
@sigoden commented on GitHub (Nov 3, 2023):
Very good idea, but there is one problem: digest-auth cannot use hashed password.
@sigoden commented on GitHub (Nov 3, 2023):
Another consideration is, is it really necessary to hash the password for basic auth?
If someone can access the system and see the password file, then it wouldn't be any harder to obtain the password through the Authorization header.
@Protinon commented on GitHub (Nov 3, 2023):
I think it's important for users who configure dufs using configuration files. In particular docker configuration using docker-compose.yml files, putting configuration inside systemd service files, or in my case I was setting up a Nix service which would contain the password.
Currently I need to be very cautious where and how I store these configuration files.
If this was implemented, I suppose digest Auth would no longer be needed.