Local file (for Development)

Detailed information on the local file secret store component

This Dapr secret store component reads plain text JSON from a given file and does not use authentication.

Setup JSON file to hold the secrets

  1. Create a JSON file (i.e. secrets.json) with the following contents:

    1. {
    2. "redisPassword": "your redis passphrase"
    3. }
  2. Save this file to your ./components directory or a secure location in your filesystem

Configure Dapr component

Create a Dapr component file (ex. localSecretStore.yaml) with following content:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: local-secret-store
  5. namespace: default
  6. spec:
  7. type: secretstores.local.file
  8. version: v1
  9. metadata:
  10. - name: secretsFile
  11. value: [path to the JSON file]
  12. - name: nestedSeparator
  13. value: ":"

The nestedSeparator parameter is optional (default value is ‘:’). It is used by the store when flattening the json hierarchy to a map.

Example

Given the following json:

  1. {
  2. "redisPassword": "your redis password",
  3. "connectionStrings": {
  4. "sql": "your sql connection string",
  5. "mysql": "your mysql connection string"
  6. }
  7. }

The store will load the file and create a map with the following key value pairs:

flattened keyvalue
“redis”“your redis password”
“connectionStrings:sql”“your sql connection string”
“connectionStrings:mysql”“your mysql connection string”

Use the flattened key (connectionStrings:sql) to access the secret.

Related links

Last modified February 16, 2021: Merge pull request #1235 from dapr/update-v0.11 (b4e9fbb)