Password Encoding
When saving user passwords, it is important to protect them against unauthorized access. For that reason, SAP Commerce Cloud Platform always stores passwords in an encoded format. You can choose from multiple encoding strategies (known as password encoders) available. In addition, you can implement your own strategies.
Currently, the SAP Commerce Cloud Platform ships with the following secure encoding strategies:
- plain text: not safe, kept for backward compatibility
- MD5: not safe, kept for backward compatibility
- SHA-512
- PBKDF2: the strongest algorithm
When editing a password, you are prompted to choose one of these strategies.
Instead of requiring you to explicitly specify the strategy, some APIs allow you to set passwords using a default strategy. The default strategy in SAP Commerce Cloud is PBKDF2. When necessary, you can change it through the default.password.encoding property. Here is an example showing how to switch from the default PBKDF2 strategy into SHA-512:
# # The code of the password encoder to use as default. These are the options (from core-spring.xml -> 'core.passwordEncoderFactory' ) # # '*' .. legacy marker for default that mapped to 'plain text' # 'plain' .. plain text # 'sha-256' .. SHA 256 # 'sha-512' .. SHA 512 # 'md5' .. MD5 # 'pbkdf2' .. PBKDF2 ( strong, configurable -> see below ) # #default.password.encoding=pbkdf2 # default.password.encoding=sha-512
Changing the default strategy this way preserves previously stored passwords (using the default strategy) so that the user can still log in. In cases where the previous strategy was considered to be unsafe, all of the previous passwords remain unsafe. Run a flex search query to find users with vulnerable passwords and passwords in clear text, then change its encoding. Following is an example how to perform that:
$passwordEncoding=sha-256 $defaultPassword=697AkzWKEkgS8Aqj9z1g $setPassword=@password[translator=de.hybris.platform.impex.jalo.translators.ConvertPlaintextToEncodedUserPasswordTranslator][default='$passwordEncoding:$defaultPassword'] INSERT_UPDATE Employee;UID[unique=true];$setPassword; ;admin; ;cmsmanager; ;cmsmanager; ;csagent; ;productmanager; ..
More information about encoding strategies can be found at Password Storage Strategies.