-
Notifications
You must be signed in to change notification settings - Fork 791
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
Support for .htpasswd Authentication (auth_plugin) #593
base: master
Are you sure you want to change the base?
Conversation
…the incoming connection + add bcrypt dependency
Nice idea! I think it would be better to have a separate auth plugin for handling auth against a password-db-file, so that your code doesn't have to be intermingled with the code in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are indicating that this should/could use htpasswd as a db-backend, it would be nice if it could support htpasswd fully, and not just bcrypt.
A dependency to passlib would help implement all the different kinds of encryption that htpasswd can use. Which are plaintext, md5, sha1, sha256, sha512, bcrypt and crypt. The check could also be implemented more manually. I think in all cases (including bcrypt which I used so far) the requirements of their respective license may apply, I think they still applies even if it is just a requirement and not a redistribution but I far from an expert on the subject. The package passlib use a custom license and bcrypt is using Apache2.0 for example. |
Passlib sounds like a great alternative. The license is OK to use 👍 |
While looking around the documentation and implementing the change I found that passlib I checked the repo because I have a warning when using the module with the latest version: (trapped) error reading bcrypt version
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/passlib/handlers/bcrypt.py", line 620, in _load_backend_mixin
version = _bcrypt.__about__.__version__
AttributeError: module 'bcrypt' has no attribute '__about__' It can be fixed by pinning the |
Good finding! It looks like maybe the fork was renamed to avoid name collisions.
Since the libpass project is alive, I think you can go with that! |
Which method should be used to determine the type of encryption of the database file :
It seems that the default encryption scheme is From what I gathered to stay inlined with the rest, it should be an additional argument, it entails to modify other files so I prefer to be sure of the proper method to follow. |
I don't think you have to do any check for which encryption is used. A htpasswd-file can contain multiple passwords with different encryption algorithms. Libpass (and htpasswd) determines which algorithm to use from a header string in the stored password hashes. From your class, it should be enough to open the htpasswd-file with |
I think you need to install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things need to be looked at, but nicely done overall! 🙂
This is a draft PR that implements authentication using a
.htpasswd
file database hosted on the server.Is it connected to #590. It also allows to authenticate multiple users.
Changes:
HtpasswdAuth
class that reads a.htpasswd
file database specified by--auth-source
.setup.py
andtest-requirements.txt
.