-
Notifications
You must be signed in to change notification settings - Fork 178
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
New hash strategies #81
Conversation
Hi! I sat down having finally found time to work on my small part and I see you have leaped ahead! Wow! I've reviewed your code and it seems really nicely done, clean and easy for me to understand despite my newness with Go. I totally missed the salt encoding option - nice. I've looked for ways I could improve it - there are a couple of comments where the search and replace 'common' for 'hashing' has left them slightly difficult to read. I could also usefully clean up my comments left in from my initial work on the argon2 functions. I'll go ahead and try to make a change to this PR to implement this as I think it is fairly uncontroversial and you can always revert them if I made a mistake. In fact, I can't see how the correct hashing functions are selected and called except in the pw.go file - unless that is also part of the regular execution? (edit - noticed your comment and perhaps this is part of the WIP.) I obviously have a way to go with go yet! |
I've got a minor tidyup commit but I get Also, both argon2 and pbkdf2 have iterations as a param but the sane defaults are like 3 and 10000 respectively! Any bright ideas how to handle that other than just signposting users? |
Yeah, it's still a WIP so a lot is missing right now. I'll try to finish everything tomorrow.
Oops, I forgot about permissions! I'm not sure git or github allow branch permissions, I'll check and see if there's any alternative to usual fork and PR. |
I certainly didn't mean to put pressure on you to work to any timescale, I hope you didn't think that! Would it help if I wrote some updated text documenting the new options for the README ? Or if you have something else please just suggest it! |
Don't worry, I didn't take it that way. As you can see, I didn't work on it yesterday after all. 😄
Definitely, that'd be very helpful. We'll need to document general hashing options and specificy what happens when missing, e.g.:
We'll also need to document needed options, valid ranges and defaults for each hasher:
Finally, we need to be able to set a specific hasher per backend and provide their options while telling it'll either use a default or plugin wise provided hasher, whatever was configured, if none is specified for a given backend, e.g.:
I'll leave any changes to the README away from this PR so you may work on it on your fork and open a different PR where we do any documentation changes. That way we won't have any trouble merging it later. |
Hey, @garethhcoleman! cc @coldfire84! I just pushed changes that - besides adding some refactoring, cleanup and other stuff -, inject a hasher to each backend that needs it: that's all but Now, there are some subtleties here: there are general hashing options as well as per backend ones, but the way it works is that in practice every backend gets a hasher and whether it uses specific options or general ones depends on the auth opts passed (see https://github.com/iegomez/mosquitto-go-auth/blob/feature/hashing-options/hashing/hashing.go#L60, and please do comment on an idea I had of adding a specific prefix for hashing options but didn't dare to implement because The PR also brings a related breaking change: salt encoding options are deprecated (sorry @coldfire84) in favor of per hasher salt encoding. The most relevant detail here is that if you don't care about the hasher and just want to use Another notable issue that you mentioned earlier has to do with the Finally, there are 2 unrelated but notable plugin issues remaining: #64 and #31. The first one needs infrastructure and, most importantly, time from me (sorry @sanhardik, now it's really on the top of my list); in the latter I'm not so sure about my initial intent: sure, Why do I mention this? Because if we manage to resolve the reported CPU issues, or they turn out to be unrelated, then once this hashing effort is done I think the related release would be a candidate to reach version 1.0! 🚀 That's why I'm adding you both, @garethhcoleman and @coldfire84, as collaborators (check your emails and ping me if you didn't receive the invitation, and @garethhcoleman, you may add any docs you were working on directly now), and asking if you can review this PR before I feel comfortable merging it and reaching that release promise. Of course, feel no pressure and instead free to say no to this request. In any case, I'm really grateful for your contributions. Cheers! |
I just pushed some changes that rename I added tests for the hashing package that cover both initializing hasher from options and generating hashes and then checking passwords against them. I've seen a random PBKDF2 failure come up from time to time when using UTF8 salt encoding, so I guessed some salts when converted to string generate the
So yay for tests, we caught a live bug! The naive solution would be to check the string form of the salt and regenerate before hashing if a |
Hiya @iegomez - happy to review, I've had a quick look just now and things are looking pretty spiffy to me, but I'll go over it more carefully in the next couple of days. Very impressed also that you managed to do this 'during a busy week at work'!! It shows the truth to the motto - "If you want something done, give it to a busy person". I debated the question of argon2 vs argon2id but for some reason decided not to mention it but I'm glad you decided to give it the correct name as we don't provide facilities to use the other variants, it is a more accurate name. I feel like I'm lucky to be involved in live development where the principles of good software (e.g. unit testing) are being demonstrated right in front of me! And I really appreciate you taking the trouble to invite me in as a collaborator when (up to now) you have put as much work into that as I am returning! But hopefully I can produce some good docs that make me a net asset! Thank you again! Its likely to take me three or four days to get an opportunity to work on this more, I hope that doesn't block anything but ping me if it does. |
@garethhcoleman @coldfire84 I've just pushed a commit that solves the salt problem and documents the hashing options. Somewhat unrelated, it solves a security issue where cache keys weren't being hashed (I know, I'm an idiot 😅), and since that's a critical one, I feel it should be merged ASAP. As I mentioned, this is a breaking change. Also, I did some testing regarding CPU problems and couldn't reproduce the issue, so I'll also release this as Thanks and cheers! |
13e8d66
to
289ad59
Compare
Fix cache security issue.
8c68836
to
aa487a9
Compare
This PR adds support for bcrypt and argon2 hashing strategies. It also refactors the awfully named commons package: opening DB and matching topics are now part of the
backends
package, while hashing and comparing are now under thehashing
package.TODO: