Skip to content

Commit f55b0f6

Browse files
authored
[board-server] Implement support for simple secrets.
- **Factor out SecretProvider and SecretManagerProvider.** - **Add SimpleSecretsProvider.** - **docs(changeset): Implement support for simple secret provider.** Fixes breadboard-ai#2963.
1 parent 19ae55b commit f55b0f6

File tree

4 files changed

+261
-98
lines changed

4 files changed

+261
-98
lines changed

.changeset/metal-queens-approve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@breadboard-ai/board-server": minor
3+
---
4+
5+
Implement support for simple secret provider.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ pids
2121
# output from markdown task
2222
all_markdown.md
2323

24+
# a file where secrets are stored
25+
secrets.json
26+
2427
# Directory for instrumented libs generated by jscoverage/JSCover
2528
lib-cov
2629

packages/board-server/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,55 @@ npm run deploy
135135
```
136136

137137
This will build the project and deploy it to App Engine.
138+
139+
## Using secrets
140+
141+
If you wish to run boards on the server, you will need to store secrets on the board server.
142+
143+
Currently, there are two choices: using [Google Cloud Secret Manager](https://cloud.google.com/security/products/secret-manager?hl=en) and using the `secrets.json` file.
144+
145+
The choice is based on the value of the `STORAGE_BACKEND` variable.
146+
147+
If the value is `sqlite`, the `secrets.json` file will be used to retrieve the secrets.
148+
149+
If the value is `firestore`, the Google Cloud Secret Manager will be used.
150+
151+
Each secret must contain three pieces of information:
152+
153+
- **name**, such as `GEMINI_KEY`. This name should match the key that the boards use to ask for this secret.
154+
155+
- **value** -- the value of the secret.
156+
157+
- **origin** -- the associated [origin](https://developer.mozilla.org/en-US/docs/Glossary/Origin) of the key. The secrets are most often used to gain access to various service APIs. To ensure that only those services can see their secret, the secrets are bound to the origin of the service.
158+
159+
### Storing secrets with `secrets.json`
160+
161+
At the root of the repository, place the file named `secrets.json`.
162+
163+
The file format is as follows:
164+
165+
```json
166+
{
167+
"SECRET_NAME_GOES_HERE": {
168+
"secret": "SECRET_VALUE_GOES_HERE",
169+
"origin": "origin/of/secret/consumer/goes/here"
170+
}
171+
}
172+
```
173+
174+
For example:
175+
176+
```json
177+
{
178+
"GEMINI_KEY": {
179+
"secret": " ...value elided..",
180+
"origin": "https://generativelanguage.googleapis.com"
181+
}
182+
}
183+
```
184+
185+
### Storing secrets with Google Cloud Secret Manager
186+
187+
Store secrets in the Secret Manager per [GCP docs](https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets).
188+
189+
For each secret, add annotation named `origin` to specify the origin of secret consumer.

0 commit comments

Comments
 (0)