Rather than hard-code a secure (but not ubiquitous) cipher in the AIRSTORY_ENCRYPTION_ALGORITHM constant, this PR adds the Airstory\Credentials\get_cipher_algorithm() function, which will find a suitable algorithm from a list of common-yet-acceptable options.
Once the algorithm is determined, this value is saved to the database (via add_site_option()), then used on all subsequent encryption/decryption requests. This practice ensures that once a site settles on an algorithm the same algorithm will be used moving forward.
This PR also adds additional tests around error cases when encrypting/decrypting user tokens, plus ensures that the cipher algorithm saved to the database is removed if the plugin is uninstalled. Fixes #53.
Rather than hard-code a secure (but not ubiquitous) cipher in the
AIRSTORY_ENCRYPTION_ALGORITHM
constant, this PR adds theAirstory\Credentials\get_cipher_algorithm()
function, which will find a suitable algorithm from a list of common-yet-acceptable options.Once the algorithm is determined, this value is saved to the database (via
add_site_option()
), then used on all subsequent encryption/decryption requests. This practice ensures that once a site settles on an algorithm the same algorithm will be used moving forward.This PR also adds additional tests around error cases when encrypting/decrypting user tokens, plus ensures that the cipher algorithm saved to the database is removed if the plugin is uninstalled. Fixes #53.