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/hydra/guides/oauth2-clients.mdx
+122Lines changed: 122 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -131,6 +131,128 @@ See [API documentation](../../reference/api#tag/oAuth2/operation/patchOAuth2Clie
131
131
</Tabs>
132
132
````
133
133
134
+
## Rotate OAuth2 client secret
135
+
136
+
OAuth2 client secret rotation allows you to change a client's secret without downtime. When you rotate a secret, the old secret remains valid until you explicitly clean it up, allowing you to update all services using the client credentials without service interruption.
137
+
138
+
### How secret rotation works
139
+
140
+
1.**Rotate the secret**: Generate a new secret for the client
141
+
2.**Both secrets work**: Old and new secrets both authenticate until cleanup
142
+
3.**Update services**: Update your applications to use the new secret
143
+
4.**Cleanup**: Manually remove old rotated secrets once all services are updated
144
+
145
+
### Rotate client secret
146
+
147
+
To rotate an OAuth2 client secret, use the following methods:
148
+
149
+
````mdx-code-block
150
+
<Tabs>
151
+
<TabItem value="rest" label="REST API">
152
+
153
+
```bash
154
+
curl -X POST https://{project.slug}.projects.oryapis.com/admin/clients/{client-id}/secret/rotate \
155
+
-H "Authorization: Bearer ory_pat_..."
156
+
```
157
+
158
+
The response includes the new `client_secret`. **Save this value immediately** - it will not be shown again.
159
+
160
+
See [API documentation](../../reference/api#tag/oAuth2/operation/oauth2RotateClientSecret).
161
+
162
+
</TabItem>
163
+
<TabItem value="sdk" label="Ory SDK">
164
+
165
+
```typescript
166
+
import { Configuration, OAuth2Api } from "@ory/client"
Secret rotation enables zero-downtime credential updates. Both the old and new secrets remain valid until you manually clean up the rotated secrets, allowing you to update all your services without service interruption.
250
+
:::
251
+
252
+
:::warning Security best practice
253
+
Rotated secrets remain valid indefinitely until you explicitly clean them up. Always remove old rotated secrets once your migration is complete to ensure that compromised credentials cannot be used.
254
+
:::
255
+
134
256
## Delete OAuth2 client
135
257
136
258
To delete an existing OAuth2 client, use the following methods:
Copy file name to clipboardExpand all lines: docs/reference/api.json
+86Lines changed: 86 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6914,6 +6914,10 @@
6914
6914
"format": "date-time",
6915
6915
"type": "string"
6916
6916
},
6917
+
"rotated_secrets": {
6918
+
"description": "OAuth 2.0 Client Rotated Secrets\n\nRotatedSecrets holds previously rotated secrets that are still valid for authentication. This allows for secret rotation without downtime. The secrets are stored in hashed format and remain valid until explicitly cleaned up.",
6919
+
"type": "string"
6920
+
},
6917
6921
"userinfo_signed_response_alg": {
6918
6922
"description": "OpenID Connect Request Userinfo Signed Response Algorithm\n\nJWS alg algorithm [JWA] REQUIRED for signing UserInfo Responses. If this is specified, the response will be JWT\n[JWT] serialized, and signed using JWS. The default, if omitted, is for the UserInfo Response to return the Claims\nas a UTF-8 encoded JSON object using the application/json content-type.",
6919
6923
"type": "string"
@@ -11948,6 +11952,88 @@
11948
11952
"tags": ["oAuth2"]
11949
11953
}
11950
11954
},
11955
+
"/admin/clients/{id}/secret/rotate": {
11956
+
"post": {
11957
+
"description": "Rotate the client secret of an OAuth 2.0 Client. The old secret will be moved to the rotated_secrets list and will remain valid until explicitly cleaned up. This allows for zero-downtime credential rotation.\n\nThe new secret will be returned in the response. Make sure to store it securely as it will not be retrievable later.",
"description": "Delete all rotated secrets from an OAuth 2.0 Client. This will revoke access for all previously rotated secrets, leaving only the current secret valid.\n\nUse this endpoint after you have updated all services to use the new secret following a rotation.",
0 commit comments