genecommerce / module-encryption-key-manager

Tooling to help generate and invalidate magento encryption keys
GNU Lesser General Public License v3.0
54 stars 14 forks source link

Add command to reencrypt specific table/column pair #10

Closed convenient closed 2 months ago

convenient commented 2 months ago

Show that everything is up to date

$ bin/magento gene:encryption-key-manager:reencrypt-column customer_entity entity_id rp_token
Run with --force to make these changes, this will run in dry-run mode by default
The latest encryption key is number 1, looking for old entries
Looking for 'rp_token' in 'customer_entity', identified by 'entity_id'
No old entries found

Then generated a new key

$ php bin/magento gene:enc:generate --force
The system currently has 2 keys
Generating a new encryption key using the magento core class
_reEncryptSystemConfigurationValues - start
_reEncryptSystemConfigurationValues - end
_reEncryptCreditCardNumbers - start
_reEncryptCreditCardNumbers - end
Cleaning cache
Done

Then ran to see a flagged issue that was corrected

$ bin/magento gene:encryption-key-manager:reencrypt-column customer_entity entity_id rp_token --force
The latest encryption key is number 3, looking for old entries
Looking for 'rp_token' in 'customer_entity', identified by 'entity_id'
########################################################################################################################
entity_id: 967427
ciphertext_old: 2:3:redacted
plaintext: abc123
ciphertext_new: 3:3:redacted
########################################################################################################################
Done

Then ran again to verify it was fixed

$ bin/magento gene:encryption-key-manager:reencrypt-column customer_entity entity_id rp_token
Run with --force to make these changes, this will run in dry-run mode by default
The latest encryption key is number 3, looking for old entries
Looking for 'rp_token' in 'customer_entity', identified by 'entity_id'
No old entries found