Step 3: Encrypt Address and Location Data
In addition to customer and payment PII, location data like street addresses and detailed zip codes must also be protected. In this step, you will extend your pipeline to encrypt address information while preserving city, state, and a partial zip code for regional analytics.
The Goal
You will enhance your processor to handle the billing_address object by:
- Encrypting the
streetandzipfields. - Creating a
zip_prefixfield containing the first 3 digits of the zip for safe regional analysis. - Deleting the original
streetandzipfields.
Implementation
-
Start with the Previous Pipeline: Copy the
encrypt-pii.yamlfile from Step 2 to a new file namedencrypt-location.yaml.cp encrypt-pii.yaml encrypt-location.yaml -
Inspect the maintained mapping: Review the selected fields, key lookup, and plaintext removal in the linked reference before adapting the processor.
See the complete configuration for the maintained encryption mapping and its ciphertext fields.
Note: Use the key variable names from the configuration you are adapting.
-
Deploy and Test:
# Send the sample payment data, which includes an address
curl -X POST http://localhost:8080/events/payment \
-H "Content-Type: application/json" \
-d @/tmp/encryption-test/sample-payment.json -
Verify: Check your logs. You will see that the
billing_addressobject now containsstreet_encrypted,zip_encrypted, and the safezip_prefix, while the original sensitive fields are gone. All the previous PII (card number, SSN, etc.) is still being encrypted correctly.
You have now built a comprehensive PII protection pipeline that covers payment, personal, and location data.