Patch #35217
closed
Replace use of Digest::MD5 / Digest::SHA1 with ActiveSupport::Digest
Added by Jens Krämer almost 5 years ago.
Updated over 1 year ago.
Category:
Code cleanup/refactoring
Description
Rails introduced ActiveSupport::Digest to allow central configuration of the actual digest implementation that is used throughout Rails. This is helpful in environments where certain digest implementations (most notably, MD5) are not available, i.e. to be FIPS compliant.
The attached patch replaces all uses of Digest::SHA1 and Digest::MD5 with ActiveSupport::Digest. Without further configuration, this will result in Digest::SHA1 being used in all these instances since that's the current Rails default. This can be changed by users via the config.active_support.hash_digest_class setting , i.e.:
Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
Files
I would suggest to just swap out MD5 for SHA256 for the Gravatar use case. It seems not practical to tie this to the hash_digest_class configuration, so let's just hard code the algorithm suggested by the Gravatar docs here.
Jens Krämer wrote in #note-3:
I would suggest to just swap out MD5 for SHA256 for the Gravatar use case. It seems not practical to tie this to the hash_digest_class configuration, so let's just hard code the algorithm suggested by the Gravatar docs here.
Agree, I've posted the patch in #40652.
yeah, it looks like https://www.gravatar.com does support SHA256 now, it wasn't supported at the time when I wrote the comment (3 years ago)
no other objections then :)
- Related to Patch #40652: Replace MD5 with SHA256 when creating the hash for gravatar URL added
- Assignee set to Marius BĂLTEANU
- Target version set to 6.0.0
- Category set to Code cleanup/refactoring
- Status changed from New to Closed
Patch committed, thanks Jens, Pavel!
Also available in: Atom
PDF