Project

General

Profile

« Previous | Next » 

Revision aa797c6b

Added by Timo Goebel about 6 years ago

fixes #23621 - passwords can be md5 hashed

View differences:

app/services/password_crypt.rb
class PasswordCrypt
ALGORITHMS = {'SHA256' => '$5$', 'SHA512' => '$6$', 'Base64' => ''}
if Foreman::Fips.md5_available?
ALGORITHMS['MD5']= '$1$'
end
def self.passw_crypt(passwd, hash_alg = 'SHA256')
raise Foreman::Exception.new(N_("Unsupported password hash function '%s'"), hash_alg) unless ALGORITHMS.has_key?(hash_alg)
result = (hash_alg == 'Base64') ? Base64.strict_encode64(passwd) : passwd.crypt("#{ALGORITHMS[hash_alg]}#{SecureRandom.base64(6)}")

Also available in: Unified diff