|
| 1 | +# PLUGIN_DYNAMIC_SECRET_STORAGE.md |
| 2 | + |
| 3 | +## Feature: Dynamic Secret Storage for Plugins/Actions |
| 4 | + |
| 5 | +**Implemented in version:** (add your current config.py version here) |
| 6 | + |
| 7 | +### Overview |
| 8 | +This feature allows plugin writers to store secrets in Azure Key Vault dynamically by simply naming any key in the plugin's `additionalFields` dictionary with the suffix `__Secret`. The application will automatically detect these keys, store their values in Key Vault, and replace the value with a Key Vault reference. This works in addition to the standard `auth.key` secret handling. |
| 9 | + |
| 10 | + |
| 11 | +### How It Works |
| 12 | +- When saving a plugin, any key in `additionalFields` ending with `__Secret` (two underscores and a capital S) will be stored in Key Vault. |
| 13 | +- The Key Vault secret name for these fields is constructed as `{pluginName-additionalsettingnamewithout__Secret}` (e.g., `loganal-alpharoemo` for plugin `loganal` and field `alpharoemo__Secret`). |
| 14 | +- The value in the plugin dict will be replaced with the Key Vault reference (the full secret name). |
| 15 | +- When retrieving a plugin, any Key Vault reference in `auth.key` or `additionalFields` ending with `__Secret` will be replaced with a UI trigger word (or optionally, the actual secret value). |
| 16 | +- When deleting a plugin, any Key Vault reference in `auth.key` or `additionalFields` ending with `__Secret` will be deleted from Key Vault. |
| 17 | + |
| 18 | + |
| 19 | +### Example |
| 20 | +```json |
| 21 | +{ |
| 22 | + "name": "loganal", |
| 23 | + "auth": { |
| 24 | + "type": "key", |
| 25 | + "key": "my-actual-secret-value" |
| 26 | + }, |
| 27 | + "additionalFields": { |
| 28 | + "alpharoemo__Secret": "supersecretvalue", |
| 29 | + "otherSetting__Secret": "anothersecret" |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | +After saving, the plugin dict will look like: |
| 34 | +```json |
| 35 | +{ |
| 36 | + "name": "loganal", |
| 37 | + "auth": { |
| 38 | + "type": "key", |
| 39 | + "key": "loganal--action--global--loganal" // Key Vault reference |
| 40 | + }, |
| 41 | + "additionalFields": { |
| 42 | + "alpharoemo__Secret": "loganal--action-addset--global--loganal-alpharoemo", // Key Vault reference |
| 43 | + "otherSetting__Secret": "loganal--action-addset--global--loganal-otherSetting" // Key Vault reference |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
| 47 | +**Note:** The Key Vault secret name for each additional setting is constructed as `{pluginName}-{additionalsettingname}` (with __Secret removed). |
| 48 | + |
| 49 | + |
| 50 | +### Benefits |
| 51 | +- No custom code required for plugin writers to leverage Key Vault for secrets. |
| 52 | +- Supports any number of dynamic secrets per plugin. |
| 53 | +- Consistent with existing agent secret handling. |
| 54 | +- Secret names are AKV-compliant and descriptive, making management and debugging easier. |
| 55 | + |
| 56 | + |
| 57 | +### Usage |
| 58 | +- To store a secret, add a key to `additionalFields` ending with `__Secret` and set its value to the secret. |
| 59 | +- The application will handle storing, retrieving, and deleting the secret in Key Vault automatically. |
| 60 | +- Secret names for additional settings will follow the `{pluginName-additionalsettingname}` pattern. |
| 61 | + |
| 62 | +### Related Files |
| 63 | +- `functions_keyvault.py` (helpers for save, get, delete) |
| 64 | +- `plugin.schema.json` (schema supports arbitrary additionalFields) |
| 65 | + |
| 66 | +### Version History |
| 67 | +- Feature added in version: (add your current config.py version here) |
| 68 | + |
| 69 | +--- |
0 commit comments