Make the generate() method more idiomatic...#326
Merged
HarlemSquirrel merged 2 commits intoruby-ldap:masterfrom Jul 5, 2020
pvdb:fix_attribute_value_warning
Merged
Make the generate() method more idiomatic...#326HarlemSquirrel merged 2 commits intoruby-ldap:masterfrom pvdb:fix_attribute_value_warning
generate() method more idiomatic...#326HarlemSquirrel merged 2 commits intoruby-ldap:masterfrom
pvdb:fix_attribute_value_warning
Conversation
HarlemSquirrel
requested changes
Jul 2, 2020
Member
HarlemSquirrel
left a comment
There was a problem hiding this comment.
Thanks for this! A small adjustment and I think this is ready.
| when :ssha | ||
| salt = SecureRandom.random_bytes(16) | ||
| attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! | ||
| '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! |
Member
There was a problem hiding this comment.
I think https://ruby-doc.org/stdlib/libdoc/base64/rdoc/Base64.html#method-i-strict_encode64 would make this even more simple and not require calling #chomp
Author
There was a problem hiding this comment.
Thanks for the feedback!
The changes in this PR (as well as the similar ones in #327 and #328) focussed on suppressing the Ruby warnings, whilst shying away from making any functional changes.
I'll gladly do the functional refactoring you suggested as well, but how do you feel about merging this PR as is, and I'll follow up immediately afterwards with the further more functional refactoring?
HarlemSquirrel
approved these changes
Jul 5, 2020
| when :ssha | ||
| salt = SecureRandom.random_bytes(16) | ||
| attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! | ||
| '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! |
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.
... and fix the following Ruby warning in the process:
Doesn't change anything functionally, and the tests still pass! 😃