Application Secrets and Configuration
Keep database URLs, API keys and other configuration in an encrypted Prism store, and let each service account read only the keys it needs.
Overview
A store is a project-scoped key-value store whose values Prism encrypts at rest.
Keys are free-form paths such as prod/database-url, and each write adds a new
version of the key. One version is the current one, which is what readers
get unless they ask for a specific version, so you can stage a new value, switch to it, and
switch back if it turns out to be wrong.
Access is granted per store, and a grant can be limited to a key prefix
(--key-prefix prod/). A service account that may read prod/ sees
neither the values nor the names of keys outside it.
Prerequisites
- A Prism project and a logged-in admin CLI profile
- A service account for the application (
payments-apibelow)
-
Create a store
prism stores create -p payments --name app-config -d "Payments service configuration" -
Write values
Values are read from
--fileor stdin and stored as raw bytes, so certificates and binary files work as well as strings.--make-currentmakes the new version the one readers get.echo -n 'postgres://payments:…@db.internal/payments' \ | prism stores values put prod/database-url -p payments --store app-config --make-current prism stores values put prod/stripe-key -p payments --store app-config \ --file stripe-key.txt --make-current prism stores values put staging/database-url -p payments --store app-config \ --file staging-db.txt --make-current prism stores values list -p payments --store app-config # retrieval_key current_version latest_version # prod/database-url 1 1 # prod/stripe-key 1 1 # staging/database-url 1 1 -
Let the application read its keys
Grant the built-in
prism:store-readerrole (stores.getandstores.list), limited to theprod/prefix:prism stores add-grant -p payments --store app-config \ --principal payments-api --effect allow \ --role prism:store-reader --key-prefix prod/Use
prism:store-writerfor a principal that should also write and delete values, or a custom role for anything in between. -
Read values from the application
With the CLI, authenticated as the service account:
prism --profile app auth sa-login-with-apikey --api-key "$PRISM_API_KEY" prism --profile app stores values get prod/database-url -p payments --store app-config prism --profile app stores values get prod/stripe-key -p payments --store app-config \ --out /run/secrets/stripe-key # Keys outside the granted prefix are denied, and not listed prism --profile app stores values get staging/database-url -p payments --store app-config # Error: HTTP 403: … policy denied action StoresGetValue for principal payments-api@…Or over HTTP with the service account's token, which returns the raw bytes (URL-encode the
/in the key as%2F):curl -fsS -H "Authorization: Bearer $TOKEN" \ https://prism.example.com/api/v1/payments/stores/app-config/values/prod%2Fdatabase-urlThe token can come from any service account login: an API key or key pair, GitHub Actions, or an EC2 instance profile, so the application needs no secret of its own to fetch its secrets.
-
Rotate and roll back
Write the new value without
--make-currentto stage it, switch to it when ready, and switch back to the previous version if needed:prism stores values put prod/stripe-key -p payments --store app-config --file new-key.txt prism stores values metadata prod/stripe-key -p payments --store app-config # current_version: 1 # latest_version: 2 prism stores values set-current prod/stripe-key -p payments --store app-config --version 2 # Roll back prism stores values set-current prod/stripe-key -p payments --store app-config --version 1 # Read an old version explicitly, or remove it for good prism stores values get prod/stripe-key -p payments --store app-config --version 1 prism stores values delete-version prod/stripe-key -p payments --store app-config --version 1
Patterns
| Goal | How |
|---|---|
| One store per environment | Separate stores (prod-config, staging-config) with separate grants |
| One store, many services | Prefix keys by service (ledger/…, api/…) and grant each service account its prefix |
| Operators rotate, apps only read | prism:store-writer for an operators group, prism:store-reader for the service accounts |
| Temporary access during an incident | Add --expires-at "2026-11-12 08:00:00" to the grant |
Auditing
Every request is audit logged with the principal, the key in the request path and the result, including denied reads:
prism org audit --org acme --limit 50
Security considerations
- Prefer key-prefix grants over store-wide grants; a store-wide
stores.getreads every key. - Grants on the project (
prism projects add-grant) apply to all its stores. The project creator holdsprism:project-admin, which includes reading all values. - Values are returned in plain text to authorized callers; write them to files with
restrictive permissions (
--out) rather than environment variables that end up in logs.