Skip to content

PhoenixKit 2.13.0: Storage bucket secrets encrypted at rest

PhoenixKit 2.13.0 encrypts the secret access key of cloud storage buckets in the database. It also lets a bucket take its credentials from an integration connection instead of storing them itself.

Bucket secrets are encrypted

A cloud bucket, on S3, Backblaze B2 or Cloudflare R2, stores an access key id and a secret access key. The secret was kept in the database as plain text. It is now encrypted when the bucket is saved, with the same encryption PhoenixKit uses for integration credentials, and decrypted only at the moment the storage provider connects. The access key id stays as it is, since it only names the key.

Existing buckets are not converted in one go. A secret saved before this version stays plain text until the bucket is saved again for any reason, and is encrypted then. Encrypted values are longer than the original, so migration V175 changes the column from 255 characters to unlimited text; without that, a long secret would not fit once encrypted.

Credentials from an integration

A bucket can now point at a connection from the Integrations module through a new integration_uuid field, instead of holding its own keys. A bucket takes one or the other: setting both in the same change is refused with a validation error, so one source never silently overrides the other. There is no picker for this in the bucket form yet; for now it is set through code.

For module authors, PhoenixKit.Integrations.Encryption gains encrypt_value/1 and decrypt_value/1 for protecting a single field.

Upgrading

Run mix phoenix_kit.update for migration V175, then open and save each cloud bucket in the storage settings if you want its secret encrypted right away. Nothing changes in how files are stored or served.

Full release notes: PhoenixKit 2.13.0

2.13.0 · 18 August 2026

Storage bucket credentials are now encrypted at rest, with an alternative credential source for cloud buckets (#732).

Added

  • phoenix_kit_buckets.integration_uuid — a cloud bucket (S3/B2/R2) may now point at a PhoenixKit.Integrations connection instead of storing access_key_id/secret_access_key directly. Mutually exclusive with the bucket’s own credentials — Bucket.changeset/2 rejects setting both in the same change rather than letting one silently win. Not yet wired up to any admin UI or a registered object_storage integration provider — usable via the context API today, a follow-up PR is expected to add the picker (#732).
  • PhoenixKit.Integrations.Encryption.encrypt_value/1 and decrypt_value/1 — single-value encrypt/decrypt for callers with one bare field to protect (e.g. an Ecto schema field) rather than a full encrypt_fields/1-shaped map. Same cipher, key derivation, and enc:v1: prefix (#732).

Changed

  • secret_access_key on storage buckets is now encrypted at rest, decrypted only at the point of use (Providers.S3.resolve_credentials/1) — general accessors like Storage.get_bucket/1 return it as stored. A row written before encryption existed stays plaintext until the next save of the bucket for any reason (no bulk backfill). access_key_id is left as-is — it is a credentials identifier, not a secret (#732).
  • phoenix_kit_buckets.secret_access_key widened from varchar(255) to text (migration V175) — the encrypted encoding runs ~1.6x the plaintext length, which overflowed the old column past a ~158-char secret (#732).

PhoenixKit 2.13.0. Install or update: {:phoenix_kit, "~> 2.13"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.