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: daprdocs/content/en/operations/security/api-token.md
+43-39Lines changed: 43 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,45 +52,12 @@ annotations:
52
52
53
53
When deployed, Dapr sidecar injector will automatically create a secret reference and inject the actual value into `DAPR_API_TOKEN` environment variable.
54
54
55
-
## Rotate a token
56
-
57
-
### Self-hosted
58
-
59
-
To rotate the configured token in self-hosted, update the `DAPR_API_TOKEN` environment variable to the new value and restart the `daprd` process.
60
-
61
-
### Kubernetes
62
-
63
-
To rotate the configured token in Kubernetes, update the previously-created secret with the new token in each namespace. You can do that using `kubectl patch` command, but a simpler way to update these in each namespace is by using a manifest:
> Assuming your service is configured with more than one replica, the key rotation process does not result in any downtime.
88
55
89
56
## Adding API token to client API invocations
90
57
91
-
Once token authentication is configured in Dapr, all clients invoking Dapr API need to append the `dapr-api-token` token to every request.
58
+
Once token authentication is configured in Dapr, all clients invoking the Dapr APIs need to append the `dapr-api-token` token to every request.
92
59
93
-
> **Note:** The Dapr SDKs read the [DAPR_API_TOKEN]({{% ref environment %}}) environment variable and set it for you by default.
60
+
> **Note:** The Dapr SDKs read the [DAPR_API_TOKEN]({{% ref environment %}}) environment variable and set it for you by default, however you still must ensure that your app has access to the environment variable.
In Kubernetes, it's recommended to mount the secret to your pod as an environment variable, as shown in the example below, where a Kubernetes secret with the name `dapr-api-token` is used to hold the token.
92
+
In Kubernetes, it's required to mount the API token on your application pod as an environment variable, when your application is making outbound calls to the Dapr APIs (Service Invocation invoke, Pub/sub publish, etc.), otherwise the request will fail with an `Unauthorized` error. Mounting the environment variable is done by providing the name of the Kubernetes secret in your application pod specification, as shown in the example below, where a Kubernetes secret with the name `dapr-api-token` is used to hold the token.
126
93
127
94
```yaml
128
95
containers:
129
96
- name: mycontainer
130
97
image: myregistry/myapp
131
-
envFrom:
132
-
- secretRef:
133
-
name: dapr-api-token
98
+
env:
99
+
- name: DAPR_API_TOKEN
100
+
valueFrom:
101
+
secretKeyRef:
102
+
name: dapr-api-token
103
+
key: token
134
104
```
135
105
136
106
### Self-hosted
@@ -141,6 +111,40 @@ In self-hosted mode, you can set the token as an environment variable for your a
141
111
export DAPR_API_TOKEN=<my-dapr-token>
142
112
```
143
113
114
+
## Rotate a token
115
+
116
+
### Self-hosted
117
+
118
+
To rotate the configured token in self-hosted, update the `DAPR_API_TOKEN` environment variable to the new value and restart the `daprd` process.
119
+
120
+
### Kubernetes
121
+
122
+
To rotate the configured token in Kubernetes, update the previously-created secret with the new token in each namespace. You can do that using `kubectl patch` command, but a simpler way to update these in each namespace is by using a manifest:
0 commit comments