You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/06-concepts/07-configuration.md
+64-2Lines changed: 64 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,15 +71,21 @@ These can be separately declared for each run mode in the corresponding yaml fil
71
71
72
72
### Secrets
73
73
74
-
Secrets are declared in the `passwords.yaml` file. The password file is structured with a common `shared` section, any secret put here will be used in all run modes. The other sections are the names of the run modes followed by respective key/value pairs.
74
+
Secrets are declared in the `passwords.yaml` file. The password file is structured with a common `shared` section, any secret put here will be used in all run modes. The other sections are the names of the run modes followed by respective key/value pairs. You can also define custom secrets using [environment variables](#2-via-environment-variables).
75
+
76
+
#### Built-in Secrets
77
+
78
+
The following table shows the built-in secrets that Serverpod uses for its core functionality. These can be configured either through environment variables or by adding the corresponding key in a respective run mode or shared section in the passwords file. These are separate from any custom passwords you might define.
@@ -91,6 +97,60 @@ Secrets are declared in the `passwords.yaml` file. The password file is structur
91
97
| SERVERPOD_AWS_ACCESS_KEY_ID | AWSAccessKeyId | - | The access key ID for AWS authentication for serverpod_cloud_storage_s3 |
92
98
| SERVERPOD_AWS_SECRET_KEY | AWSSecretKey | - | The secret key for AWS authentication for serverpod_cloud_storage_s3 |
93
99
100
+
#### Custom Secrets
101
+
102
+
You can define your own custom secrets in two ways.
103
+
104
+
##### 1. Via Passwords File
105
+
106
+
Add your custom secrets directly to the passwords file under the `shared` section (available in all run modes) or under specific run mode sections.
107
+
108
+
```yaml
109
+
shared:
110
+
myCustomSharedSecret: 'secret_key'
111
+
stripeApiKey: 'sk_test_123...'
112
+
113
+
development:
114
+
database: 'development_password'
115
+
redis: 'development_password'
116
+
serviceSecret: 'development_service_secret'
117
+
twilioApiKey: 'dev_twilio_key'
118
+
119
+
production:
120
+
database: 'production_password'
121
+
redis: 'production_password'
122
+
serviceSecret: 'production_service_secret'
123
+
twilioApiKey: 'prod_twilio_key'
124
+
```
125
+
126
+
##### 2. Via Environment Variables
127
+
128
+
You can also define custom passwords using environment variables with the `SERVERPOD_PASSWORD_` prefix. For example, `SERVERPOD_PASSWORD_myApiKey` will be available as `myApiKey` (the prefix is stripped). These environment variables will override any passwords defined in the passwords file if the name (after stripping the prefix) matches. Like the `shared` section in the passwords file, these environment variables are available in all run modes.
| SERVERPOD_PASSWORD\_\* | Custom password that will be available in the Session.passwords map. The prefix `SERVERPOD_PASSWORD_` will be stripped from the key name. |
133
+
134
+
**Example:**
135
+
136
+
To define a custom password through an environment variable:
You can then access any custom password (whether defined in the passwords file or via environment variables) in your endpoint code through the `Session.passwords` map:
final stripeApiKey = session.passwords['stripeApiKey'];
149
+
// Use the API key to make requests to Stripe
150
+
...
151
+
}
152
+
```
153
+
94
154
### Config file example
95
155
96
156
The config file should be named after the run mode you start the server in and it needs to be placed inside the `config` directory in the root of the server project. As an example, you have the `config/development.yaml` that will be used when running in the `development` run mode.
0 commit comments