diff --git a/composer.json b/composer.json index a0a67e7..de464a9 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "24unix/bindapi", "description": "manage Bind9 DNS server via REST API", "version": "1.0.9", - "build_number": "355", + "build_number": "356", "authors": [ { "name": "Micha Espey", @@ -30,7 +30,7 @@ "robmorgan/phinx": "^0.15", "symfony/property-access": "^6.1", "symfony/serializer": "^6.1", - "zircote/swagger-php": "^4.2" + "zircote/swagger-php": "^4.8" }, "config": { "optimize-autoloader": true, diff --git a/composer.lock b/composer.lock index 10d0632..14018f4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "39a97c9f763fcd937f90143307fa8185", + "content-hash": "5dbbe0ea570912e4a3664e4798edaccd", "packages": [ { "name": "arubacao/tld-checker", - "version": "1.2.228", + "version": "1.2.229", "source": { "type": "git", "url": "https://github.com/arubacao/tld-checker.git", - "reference": "2b203b2ceac5bad62fed07f1613c9cf118fe6f96" + "reference": "194a704aef0b5e07b5695c5a2769f664e7cf9185" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/arubacao/tld-checker/zipball/2b203b2ceac5bad62fed07f1613c9cf118fe6f96", - "reference": "2b203b2ceac5bad62fed07f1613c9cf118fe6f96", + "url": "https://api.github.com/repos/arubacao/tld-checker/zipball/194a704aef0b5e07b5695c5a2769f664e7cf9185", + "reference": "194a704aef0b5e07b5695c5a2769f664e7cf9185", "shasum": "" }, "require": { @@ -65,9 +65,9 @@ ], "support": { "issues": "https://github.com/arubacao/tld-checker/issues", - "source": "https://github.com/arubacao/tld-checker/tree/1.2.228" + "source": "https://github.com/arubacao/tld-checker/tree/1.2.229" }, - "time": "2024-04-14T04:01:22+00:00" + "time": "2024-04-21T04:01:27+00:00" }, { "name": "cakephp/chronos", @@ -4116,16 +4116,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.1", + "version": "3.9.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", "shasum": "" }, "require": { @@ -4192,7 +4192,7 @@ "type": "open_collective" } ], - "time": "2024-03-31T21:03:09+00:00" + "time": "2024-04-23T20:25:34+00:00" }, { "name": "theseer/tokenizer", diff --git a/dist/systemd/bindAPI.service b/dist/systemd/bindAPI.service index 1a31dd5..0d45d74 100644 --- a/dist/systemd/bindAPI.service +++ b/dist/systemd/bindAPI.service @@ -2,4 +2,5 @@ Description=BindAPI Service to check zone file and reload configuration [Service] +User= ExecStart=/home/users///bin/console -q cron:run diff --git a/public/index.php b/public/index.php index 37f2c57..30efbf9 100644 --- a/public/index.php +++ b/public/index.php @@ -6,10 +6,15 @@ error_reporting(error_level: E_ALL); require dirname(path: __DIR__) . '/vendor/autoload.php'; -$uri = parse_url(url: $_SERVER['REQUEST_URI'], component: PHP_URL_PATH); -$uri = explode(separator: '/', string: $uri); +$parsedUrl = parse_url(url: $_SERVER['REQUEST_URI'], component: PHP_URL_PATH); +$uri = explode(separator: '/', string: $parsedUrl); -if ($uri[1] !== 'api') { +$baseRoutes = ['app', 'api']; +$uriPrefix = $uriFirstThreeLetters = substr(string: $uri[1], offset: 0, length: 3); + + +if (!in_array(needle: $uriPrefix, haystack: $baseRoutes)) { + // only handle $baseRoutes, elso go to swagger ui $scheme = $_SERVER['REQUEST_SCHEME']; $host = $_SERVER['SERVER_NAME']; $header = "$scheme://$host/openapi/index.html"; @@ -25,6 +30,12 @@ header(header: "Access-Control-Allow-Headers: Content-Type, Access-Control-Allow $requestMethod = $_SERVER["REQUEST_METHOD"]; +if ($requestMethod === "OPTIONS") { + // Respond with OK status code for preflight requests + http_response_code(response_code: 200); + exit(); +} + try { $app = new BindAPI(quiet: false); $app->handleRequest(requestMethod: $requestMethod, uri: $uri); diff --git a/public/openapi/index.html b/public/openapi/index.html index 05ecd41..33015a7 100644 --- a/public/openapi/index.html +++ b/public/openapi/index.html @@ -19,8 +19,9 @@