diff --git a/.gitignore b/.gitignore index db3aa6f..4a359db 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ Thumbs.db /coverage/ /build/ +/build.tar.gz /builds /phpunit.xml.cache /.phpunit.result.cache diff --git a/README.md b/README.md index 89acb7e..da0bac8 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Problems with it can be raised on our forum, or as issues in the main repository ## Server Requirements -PHP version 8.1 or higher is required, with the following extensions installed: +PHP version 8.5 or higher is required, with the following extensions installed: - [intl](http://php.net/manual/en/intl.requirements.php) - [mbstring](http://php.net/manual/en/mbstring.installation.php) @@ -71,7 +71,7 @@ PHP version 8.1 or higher is required, with the following extensions installed: > - The end of life date for PHP 7.4 was November 28, 2022. > - The end of life date for PHP 8.0 was November 26, 2023. > - If you are still using PHP 7.4 or 8.0, you should upgrade immediately. -> - The end of life date for PHP 8.1 will be December 31, 2025. +> - The end of life date for PHP 8.1 was December 31, 2025. Additionally, make sure that the following extensions are enabled in your PHP: diff --git a/README.txt b/README.txt deleted file mode 100644 index 9f533f7..0000000 --- a/README.txt +++ /dev/null @@ -1,32 +0,0 @@ -Al Rahma Sunday School — API Docs Pack -================================================= -Generated: 2025-11-07T21:01:43.815073 - -WHAT'S INCLUDED ---------------- -- app/Controllers/Api/*.php (API controllers) -- app/Controllers/{DocsController, ApiDocsController} -- app/Filters/ApiDocsAuthFilter.php -- app/Views/docs/{index.php, swagger_ui.php, swagger_ui_public.php} -- public/docs/openapi/*.yaml (separate specs + master.yaml) -- ROUTES_SNIPPET.php (add to app/Config/Routes.php) -- FILTERS_SNIPPET.php (add alias to app/Config/Filters.php) - -INSTALL -------- -1) Unzip into your project root. -2) Merge routes: - - Open app/Config/Routes.php and paste the contents of ROUTES_SNIPPET.php -3) Add filter alias: - - Open app/Config/Filters.php and add the 'apiDocsAuth' alias from FILTERS_SNIPPET.php -4) Ensure your Models exist and match the controller expectations. -5) Set JWT secret in .env: - JWT_SECRET=your_super_secret_key -6) Visit: - - /docs (landing) - - /docs/api (secured, admin only) - - /docs/api/public (public read-only) -7) API base path: - - /api/v1/... (see YAMLs for full paths) - -Enjoy! diff --git a/app/Config/ContentSecurityPolicy.php b/app/Config/ContentSecurityPolicy.php index 2ac41a7..e4dbca0 100644 --- a/app/Config/ContentSecurityPolicy.php +++ b/app/Config/ContentSecurityPolicy.php @@ -47,28 +47,63 @@ class ContentSecurityPolicy extends BaseConfig * * @var list|string|null */ - public $defaultSrc; + public $defaultSrc = 'self'; /** * Lists allowed scripts' URLs. * * @var list|string */ - public $scriptSrc = 'self'; + public $scriptSrc = [ + 'self', + 'unsafe-inline', + 'https://cdn.jsdelivr.net', + 'https://code.jquery.com', + 'https://cdnjs.cloudflare.com', + ]; /** * Lists allowed stylesheets' URLs. * * @var list|string */ - public $styleSrc = 'self'; + public $styleSrc = [ + 'self', + 'unsafe-inline', + 'https://cdn.jsdelivr.net', + 'https://fonts.googleapis.com', + 'https://cdnjs.cloudflare.com', + ]; + + /** + * Lists allowed stylesheet element URLs. + * + * @var list|string + */ + public $styleSrcElem = [ + 'self', + 'unsafe-inline', + 'https://cdn.jsdelivr.net', + 'https://fonts.googleapis.com', + 'https://cdnjs.cloudflare.com', + ]; + + /** + * Allows inline style attributes used by legacy views. + * + * @var list|string + */ + public $styleSrcAttr = [ + 'self', + 'unsafe-inline', + ]; /** * Defines the origins from which images can be loaded. * * @var list|string */ - public $imageSrc = 'self'; + public $imageSrc = ['self', 'data:', 'https:']; /** * Restricts the URLs that can appear in a page's `` element. @@ -99,7 +134,13 @@ class ContentSecurityPolicy extends BaseConfig * * @var list|string */ - public $fontSrc; + public $fontSrc = [ + 'self', + 'data:', + 'https://fonts.gstatic.com', + 'https://cdn.jsdelivr.net', + 'https://cdnjs.cloudflare.com', + ]; /** * Lists valid endpoints for submission from `
` tags. diff --git a/app/Views/docs/swagger_ui.php b/app/Views/docs/swagger_ui.php index 4bea457..fc230a1 100644 --- a/app/Views/docs/swagger_ui.php +++ b/app/Views/docs/swagger_ui.php @@ -4,7 +4,7 @@ + content="default-src 'self'; connect-src 'self' http://localhost:8080 https://cdnjs.cloudflare.com; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://cdnjs.cloudflare.com; img-src 'self' data:; font-src 'self' https://fonts.gstatic.com https://cdnjs.cloudflare.com;" /> Al Rahma Sunday School — API Docs