API-Reife: Scopes (read/write), Rate-Limit pro Key, OpenAPI-Spec
- ApiKey::hasScope + checkRateLimit (Fixed-Window/min via api_key_hits) - bootstrap erzwingt Rate-Limit (429) und api_require_scope() in Endpunkten - admin/api_keys.php: Scope-Auswahl + Limit beim Erstellen, Anzeige in Tabelle - api/openapi.php: OpenAPI-3.0-Spec (Import in Postman/Swagger) - Schema 0003 (api_keys.scope, api_keys.rate_limit, Tabelle api_key_hits)
This commit is contained in:
parent
ba121d60e6
commit
c7f9b7d39c
6 changed files with 146 additions and 4 deletions
|
|
@ -16,6 +16,7 @@ require_once __DIR__ . '/../includes/Notifier.php';
|
|||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
if ($method === 'GET') {
|
||||
api_require_scope('read');
|
||||
$siteId = (int)($_GET['site_id'] ?? 0);
|
||||
if ($siteId <= 0) {
|
||||
api_json(['error' => 'invalid_request', 'message' => 'site_id erforderlich'], 400);
|
||||
|
|
@ -29,6 +30,7 @@ if ($method === 'GET') {
|
|||
}
|
||||
|
||||
if ($method === 'POST') {
|
||||
api_require_scope('write');
|
||||
$body = api_body();
|
||||
$siteId = (int)($body['site_id'] ?? 0);
|
||||
$name = trim((string)($body['name'] ?? ''));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue