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

Implement password hashing with argon2-cffi #3793

Merged
merged 4 commits into from
Jul 10, 2020
Merged

Implement password hashing with argon2-cffi #3793

merged 4 commits into from
Jul 10, 2020

Conversation

remram44
Copy link
Contributor

Fixes #2426

The hashlib hashing method could probably be removed from passwd() since nothing ever specifies the algorithm argument. Should probably be kept in passwd_check() until people update their configs.

@nealmcb
Copy link

nealmcb commented Sep 7, 2019

Thank you - I agree that the current non-iterated use of SHA-1 is awful.
But as I noted at #2426 (comment), I think hashlib.pbkdf2_hmac which is already in standard Python might be more appropriate.

I also think it is now clear that Argon2 is better than bcrypt, and I wonder if using it (and adding a dependency on it) instead of bcrypt might be more appropriate now.

Or maybe Argon2 will come to the standard Python3 library soon?
Anyway, thanks!

@remram44
Copy link
Contributor Author

remram44 commented Sep 8, 2019

I'm happy to make further changes and look into stdlib facilities if/when a project member expresses interest in this.

@blink1073
Copy link
Contributor

Hi @remram44, we're catching up on PR review. I'd support the use of hashlib.pbkdf2_hmac as a compromise that improves the hashing without taking on an external dependency. Are you able to pick this work back up?

@nealmcb
Copy link

nealmcb commented Jun 12, 2020

I wonder if scrypt is appropriate by now. scrypt is significantly better than pbkdf2, since it is memory-hard, and is supported in Python 3.6 (scrypt), and requires OpenSSL 1.1+

I also note this interesting reflection on argon2: https://twitter.com/Sc00bzT/status/1149950559258140673

@blink1073
Copy link
Contributor

I'll defer to your expertise here @nealmcb. Given that argon2 is available on conda-forge I'd support taking it on as a dependency.

@nealmcb
Copy link

nealmcb commented Jun 13, 2020

I have some thoughts that I'll take to the main issue #2426.

@remram44
Copy link
Contributor Author

This can easily be updated to another method, if a consensus is reached.

@blink1073
Copy link
Contributor

@remram44 if you make these changes I'll go ahead and merge: #2426 (comment)

@blink1073 blink1073 added this to the 6.1 milestone Jun 27, 2020
@remram44
Copy link
Contributor Author

remram44 commented Jul 8, 2020

I rebased, and switched to argon2-cffi as requested.

A point that was mentioned by @nealmcb was making the Argon2 parameters configurable via jupyter_notebook_config.py, however I am not sure that loading that config file in passwd() is appropriate. Also I am a little confused about the different approaches in dealing with the config file (this vs this).

@blink1073
Copy link
Contributor

It looks like auth/__main__.py should be calling out to auth/secruity.py (needs a refactor).
I think we can take up optimizations in further PRs, let's merge and iterate.

@CaselIT
Copy link

CaselIT commented Mar 18, 2021

Any reason this was not also added to jupyter_server and ipython that have the same implementation of these functions?

@remram44
Copy link
Contributor Author

I don't think jupyter_server existed when I opened this PR. It took 2 years to merge.

@nealmcb
Copy link

nealmcb commented Mar 19, 2021

Thanks to everyone for getting this wrapped up last year.
It might help to change the title line of this issue, to clarify that we ended up using argon2_cffi, not bcrypt. I guess perhaps only the owner can do that?

@kevin-bates kevin-bates changed the title Implement password hashing with bcrypt Implement password hashing with argon2-cffi Mar 19, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

default password hash of sha-1 is insecure
4 participants