- 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)
15 lines
495 B
PHP
15 lines
495 B
PHP
<?php
|
||
/**
|
||
* GET /api/sites.php – Liste aktiver Sites (für API-Clients).
|
||
*/
|
||
require_once __DIR__ . '/bootstrap.php';
|
||
|
||
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||
api_json(['error' => 'method_not_allowed'], 405);
|
||
}
|
||
api_require_scope('read');
|
||
|
||
$sites = $db->fetchAll("SELECT id, name, site_id FROM sites WHERE is_active = 1 ORDER BY name");
|
||
api_json(['sites' => array_map(function ($s) {
|
||
return ['id' => (int)$s['id'], 'name' => $s['name'], 'site_id' => $s['site_id']];
|
||
}, $sites)]);
|