Add SHA2, :smd5, :sha1 & :ssha1 password generation support#201
Open
ojab wants to merge 1 commit intoruby-ldap:masterfrom
Open
Add SHA2, :smd5, :sha1 & :ssha1 password generation support#201ojab wants to merge 1 commit intoruby-ldap:masterfrom
ojab wants to merge 1 commit intoruby-ldap:masterfrom
Conversation
|
Note that in this pull request, if the password contains accented characters, the following error will be thrown: There's the option of forcing the encoding of the password to ASCII, but I think the more elegant solution is to use algo = Digest.module_eval(digest.upcase).new
algo.update(str)
algo.update(salt)
"{#{type.upcase}}#{Base64.encode64(algo.digest + salt).chomp}" |
Member
jch
suggested changes
Jan 25, 2017
| attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp! | ||
| when :ssha | ||
| salt = SecureRandom.random_bytes(16) | ||
| attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! |
Member
There was a problem hiding this comment.
Can we keep the same pattern here without introducing a KNOWN constant? Yes, there is more duplication, but it's simpler to reason about in my opinion and more obvious to grep for than hiding the information via lookups and module_evals.
Member
|
@ojab would you like to update this branch and get these other hash algorithms in here now? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Haven't tested this PR on rubies < 2.2 yet, please consider it RFC.
With this patch net/ldap will support md5, sha, sha1, sha256, sha384, sha512 password schemes (and salted variants).
Given that comment says "I vote no because then should you also provide ssha1 for symmetry?" -- should I remove :sha1/:ssha1 support?
Is the code overall looks ok for you or something should be changed?