Quickstart
This quickstart for Customer-managed keys encrypts one value under a cloud key you connect as a test customer. You decrypt it, disable the key, and watch decryption fail.
alien examples encryption-gateway --operation encrypt --key-id customer-dataEvery step uses the Alien CLI. Run them from a directory linked to your Alien project.
Turn it on
Turn on customer-managed keys for the project and create an API key that can only call the Encrypt/Decrypt API, which encrypts with each customer's key:
alien projects capabilities enable encryption
alien api-keys create --for encryption-gateway --description local-quickstartThe secret is shown once. Save it, with the external ID you'll use for this test customer:
export ALIEN_ENCRYPTION_API_KEY="..."
export CUSTOMER_ID="org_test"Connect a test key
Create a setup link for the test customer:
alien onboard "Test customer" --external-id "$CUSTOMER_ID" --setup-items keysOpen the printed link. In the deployment portal, the branded setup page Alien hosts, connect a key from an AWS, Google Cloud, or Azure account you control.
Encrypt a value
Print a ready-to-run request for your environment:
alien examples encryption-gateway --operation encrypt --key-id customer-dataRun the printed command. It's equivalent to the request below. The API takes and returns base64: aGVsbG8= is hello.
curl "https://encryption.alien.dev/v1/encrypt" \
-H "Authorization: Bearer $ALIEN_ENCRYPTION_API_KEY" \
-H "X-Alien-External-ID: $CUSTOMER_ID" \
-H "Content-Type: application/json" \
-d '{"key": {"keyId": "customer-data"}, "plaintext": "aGVsbG8="}'Save the returned ciphertext:
export CIPHERTEXT="..."Decrypt it
alien examples encryption-gateway --operation decrypt --key-id customer-dataThe printed request reads ALIEN_ENCRYPTION_API_KEY, CUSTOMER_ID, and CIPHERTEXT. The response holds the plaintext as base64.
Disable the key
- Disable the test key in your cloud console.
- Wait longer than 5 minutes, the time Alien caches the customer's encryption root.
- Decrypt again. It fails with
KEY_UNAVAILABLE. - Re-enable the key and confirm decrypt works again.
If a result is unexpected, search the request log. It records metadata, never values:
alien logs --source encryption-gateway --operation decrypt --since 1hDecide how your product behaves while a customer's key is unavailable before you ship.
Next
- Add to your product: the settings page and the encrypt calls in your backend
- Data and keys: what Alien sees and how revocation works
Overview
Let each customer hold the key that makes their data readable, in their own AWS KMS, Google Cloud KMS, or Azure Key Vault, and revoke it at any time.
Add to your product
Build a Customer-managed keys settings page into a product you host. The customer connects a key in their cloud; your backend encrypts through the Encrypt/Decrypt API.