API keys: Return 410 Gone status from POST /auth/keys endpoint (#92965)

* return 410 Gone status from POST /auth/keys endpoint

* generate swagger

* remove postAPIkeyResponse

* re-generate swagger

* remove docs for api key creation endpoint
This commit is contained in:
Mihai Doarna
2024-09-05 13:10:24 +03:00
committed by GitHub
parent de5bbd2539
commit ebd17adecf
6 changed files with 40 additions and 75 deletions
+2 -36
View File
@@ -89,47 +89,13 @@ Endpoint is obsolete and has been moved to [Grafana service account API]({{< rel
`POST /api/auth/keys`
**Required permissions**
See note in the [introduction]({{< ref "#authentication-api" >}}) for an explanation.
| Action | Scope |
| ---------------- | ----- |
| `apikeys:create` | n/a |
**Example Request**:
```http
POST /api/auth/keys HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"name": "mykey",
"role": "Admin",
"secondsToLive": 86400
}
```
JSON Body schema:
- **name** The key name
- **role** Sets the access level/Grafana Role for the key. Can be one of the following values: `None`, `Viewer`, `Editor` or `Admin`.
- **secondsToLive** Sets the key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless `api_key_max_seconds_to_live` configuration option is set) the key will never expire.
Error statuses:
- **400** `api_key_max_seconds_to_live` is set but no `secondsToLive` is specified or `secondsToLive` is greater than this value.
- **500** The key was unable to be stored in the database.
**Example Response**:
```http
HTTP/1.1 301
HTTP/1.1 410
Content-Type: application/json
""
{"message":"this endpoint has been removed, please use POST /api/serviceaccounts and POST /api/serviceaccounts/{id}/tokens instead"}
```
## Delete API Key