From 4d94fe6c2f709d1c3316598762c149576e11f2f0 Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 9 Apr 2024 16:15:25 +0300 Subject: [PATCH 01/11] Added documentation for v3 --- .github/workflows/continuous-integration.yml | 11 ++++ .github/workflows/cs-tests.yml | 47 ---------------- .github/workflows/docs-build.yml | 16 ++++++ .github/workflows/static-analysis.yml | 47 ---------------- .github/workflows/unit-tests.yml | 48 ---------------- README.md | 2 + SECURITY.md | 38 +++++++++++++ docs/book/index.md | 1 + docs/book/v3/configuration.md | 58 ++++++++++++++++++++ docs/book/v3/installation.md | 5 ++ docs/book/v3/overview.md | 3 + docs/book/v3/usage.md | 24 ++++++++ mkdocs.yml | 19 +++++++ 13 files changed, 177 insertions(+), 142 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .github/workflows/cs-tests.yml create mode 100644 .github/workflows/docs-build.yml delete mode 100644 .github/workflows/static-analysis.yml delete mode 100644 .github/workflows/unit-tests.yml create mode 100644 SECURITY.md create mode 100644 docs/book/index.md create mode 100644 docs/book/v3/configuration.md create mode 100644 docs/book/v3/installation.md create mode 100644 docs/book/v3/overview.md create mode 100644 docs/book/v3/usage.md create mode 100644 mkdocs.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..72dde2f --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,11 @@ +name: "Continuous Integration" + +on: + pull_request: + push: + branches: + tags: + +jobs: + ci: + uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x diff --git a/.github/workflows/cs-tests.yml b/.github/workflows/cs-tests.yml deleted file mode 100644 index e8bbade..0000000 --- a/.github/workflows/cs-tests.yml +++ /dev/null @@ -1,47 +0,0 @@ -on: - - push - -name: Run phpcs checks - -jobs: - mutation: - name: PHP ${{ matrix.php }}-${{ matrix.os }} - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: - - ubuntu-latest - - php: - - "8.1" - - "8.2" - - "8.3" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: composer:v2, cs2pr - coverage: none - - - name: Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php }}-composer- - - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run phpcs checks - run: vendor/bin/phpcs diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml new file mode 100644 index 0000000..f9be9e2 --- /dev/null +++ b/.github/workflows/docs-build.yml @@ -0,0 +1,16 @@ +name: docs-build + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build-deploy: + runs-on: ubuntu-latest + steps: + - name: Build Docs + uses: dotkernel/documentation-theme/github-actions/docs@main + env: + DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml deleted file mode 100644 index 6f7452d..0000000 --- a/.github/workflows/static-analysis.yml +++ /dev/null @@ -1,47 +0,0 @@ -on: - - push - -name: Run static analysis - -jobs: - mutation: - name: PHP ${{ matrix.php }}-${{ matrix.os }} - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: - - ubuntu-latest - - php: - - "8.1" - - "8.2" - - "8.3" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: composer:v2, cs2pr - coverage: none - - - name: Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php }}-composer- - - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run static analysis - run: vendor/bin/psalm --no-cache --output-format=github --show-info=false --threads=4 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index 7f5f333..0000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,48 +0,0 @@ -on: - - push - -name: Run PHPUnit tests - -jobs: - mutation: - name: PHP ${{ matrix.php }}-${{ matrix.os }} - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: - - ubuntu-latest - - php: - - "8.1" - - "8.2" - - "8.3" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: composer:v2, cs2pr - coverage: none - - - name: Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php }}-composer- - - - name: Install dependencies with composer - run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run PHPUnit tests - run: vendor/bin/phpunit --colors=always diff --git a/README.md b/README.md index 5d0c509..e52c744 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Middleware for setting and overwriting custom response headers. ### Requirements + - PHP >= 8.1 ### Installation @@ -78,6 +79,7 @@ All headers under ``*`` will be set for every response. To add response headers for a specific set of routes, define a new array using the route name as the array key. Example : + ``` 'dot_response_headers' => [ 'user' => [ diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..049f4a0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,38 @@ +# Security Policy + +## Supported Versions + + +| Version | Supported | PHP Version | +|---------|--------------------|---------------------------------------------------------------------------------------------------------------------| +| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-response-header/3.2.3) | + + +## Reporting Potential Security Issues + +If you have encountered a potential security vulnerability in this project, +please report it to us at . We will work with you to +verify the vulnerability and patch it. + +When reporting issues, please provide the following information: + +- Component(s) affected +- A description indicating how to reproduce the issue +- A summary of the security vulnerability and impact + +We request that you contact us via the email address above and give the +project contributors a chance to resolve the vulnerability and issue a new +release prior to any public exposure; this helps protect the project's +users, and provides them with a chance to upgrade and/or update in order to +protect their applications. + + +## Policy + +If we verify a reported security vulnerability, our policy is: + +- We will patch the current release branch, as well as the immediate prior minor + release branch. + +- After patching the release branches, we will immediately issue new security + fix releases for each patched release branch. diff --git a/docs/book/index.md b/docs/book/index.md new file mode 100644 index 0000000..4c0539a --- /dev/null +++ b/docs/book/index.md @@ -0,0 +1 @@ +../../README.md diff --git a/docs/book/v3/configuration.md b/docs/book/v3/configuration.md new file mode 100644 index 0000000..a19c004 --- /dev/null +++ b/docs/book/v3/configuration.md @@ -0,0 +1,58 @@ +# Configuration + +## Requirements + +- PHP >= 8.1 + +## Register ConfigProvider + +Next, register the package's `ConfigProvider` to your application config. + + +```php +Dot\ResponseHeader\ConfigProvider::class, +``` + +Note : Make sure to register the package under the `// DK packages` section. + +## Add the package to the middleware stack + +After registering the package, add it to the middleware stack in `config/pipeline.php` after `$app->pipe(RouteMiddleware::class);` + +```php +$app->pipe(RouteMiddleware::class); +$app->pipe(\Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware::class); +``` + +## Add configuration in autoload + +Create a new file `response-header.global.php` in `config/autoload` with the below configuration array : + +```php + [ + '*' => [ + 'CustomHeader1' => [ + 'value' => 'CustomHeader1-Value', + 'overwrite' => true, + ], + 'CustomHeader2' => [ + 'value' => 'CustomHeader2-Value', + 'overwrite' => false, + ], + ], + 'home' => [ + 'CustomHeader' => [ + 'value' => 'header3', + ] + ], + 'login' => [ + 'LoginHeader' => [ + 'value' => 'LoginHeader-Value', + 'overwrite' => false + ] + ], + ] +]; +``` diff --git a/docs/book/v3/installation.md b/docs/book/v3/installation.md new file mode 100644 index 0000000..3bded62 --- /dev/null +++ b/docs/book/v3/installation.md @@ -0,0 +1,5 @@ +# Installation + +Install dotkernel/dot-response-header by executing the following Composer command in your project directory: + + $ composer require dotkernel/dot-response-header diff --git a/docs/book/v3/overview.md b/docs/book/v3/overview.md new file mode 100644 index 0000000..d57c953 --- /dev/null +++ b/docs/book/v3/overview.md @@ -0,0 +1,3 @@ +# Overview + +`dot-response-header` is DotKernel's middleware for setting and overwriting custom response headers. diff --git a/docs/book/v3/usage.md b/docs/book/v3/usage.md new file mode 100644 index 0000000..3e5f8d7 --- /dev/null +++ b/docs/book/v3/usage.md @@ -0,0 +1,24 @@ +# Usage + +Because headers are matched with route names, we can have custom response headers for every request, by defining new headers under the `*` key, in the configuration file `response-header.global.php`. + +All headers under `*` will be set for every response. + +To add response headers for a specific set of routes, define a new array using the route name as the array key. + +## Example + +```php +'dot_response_headers' => [ + 'user' => [ + 'UserCustomHeader' => [ + 'value' => 'UserCustomHeader-Value', + 'overwrite' => false + ] + ], +] + +// This will set a new header named UserCustomHeader with the UserCustomHeader-Value value for any route name matching 'user' +``` + +To overwrite an existing header use `overwrite => true`. diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..c2feaa5 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,19 @@ +docs_dir: docs/book +site_dir: docs/html +extra: + project: Packages + current_version: v3 + versions: + - v3 +nav: + - Home: index.md + - v3: + - Overview: v5/overview.md + - Installation: v5/installation.md + - Usage: v5/usage.md + - Factories: v5/factories.md +site_name: dot-response-header +site_description: "DotKernel's middleware for setting and overwriting custom response headers." +repo_url: "https://github.com/dotkernel/dot-response-header" +plugins: + - search \ No newline at end of file From fc202c6821f22d858d730caa9378fba9bf38fa63 Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 9 Apr 2024 16:20:59 +0300 Subject: [PATCH 02/11] Fixing CI errors --- docs/book/v3/configuration.md | 3 +-- mkdocs.yml | 38 +++++++++++++++++------------------ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/docs/book/v3/configuration.md b/docs/book/v3/configuration.md index a19c004..330b18b 100644 --- a/docs/book/v3/configuration.md +++ b/docs/book/v3/configuration.md @@ -1,14 +1,13 @@ # Configuration ## Requirements - + - PHP >= 8.1 ## Register ConfigProvider Next, register the package's `ConfigProvider` to your application config. - ```php Dot\ResponseHeader\ConfigProvider::class, ``` diff --git a/mkdocs.yml b/mkdocs.yml index c2feaa5..f979693 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,19 +1,19 @@ -docs_dir: docs/book -site_dir: docs/html -extra: - project: Packages - current_version: v3 - versions: - - v3 -nav: - - Home: index.md - - v3: - - Overview: v5/overview.md - - Installation: v5/installation.md - - Usage: v5/usage.md - - Factories: v5/factories.md -site_name: dot-response-header -site_description: "DotKernel's middleware for setting and overwriting custom response headers." -repo_url: "https://github.com/dotkernel/dot-response-header" -plugins: - - search \ No newline at end of file +docs_dir: docs/book +site_dir: docs/html +extra: + project: Packages + current_version: v3 + versions: + - v3 +nav: + - Home: index.md + - v3: + - Overview: v5/overview.md + - Installation: v5/installation.md + - Usage: v5/usage.md + - Factories: v5/factories.md +site_name: dot-response-header +site_description: "DotKernel's middleware for setting and overwriting custom response headers." +repo_url: "https://github.com/dotkernel/dot-response-header" +plugins: + - search From 64d090906fa243b873cb9e662de176456a4bc1df Mon Sep 17 00:00:00 2001 From: nati Date: Wed, 10 Apr 2024 14:11:39 +0300 Subject: [PATCH 03/11] Fixing CI errors --- README.md | 83 +++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index e52c744..4359a76 100644 --- a/README.md +++ b/README.md @@ -13,26 +13,22 @@ [![SymfonyInsight](https://insight.symfony.com/projects/dce88959-bd29-40ef-b1e7-d12815145438/big.svg)](https://insight.symfony.com/projects/dce88959-bd29-40ef-b1e7-d12815145438) - Middleware for setting and overwriting custom response headers. - -### Requirements +## Requirements - PHP >= 8.1 -### Installation +## Installation Run the following command in your project root directory composer require dotkernel/dot-response-header - Next, register the package's `ConfigProvider` to your application config. Dot\ResponseHeader\ConfigProvider::class, - Note : Make sure to register the package under the `// DK packages` section. After registering the package, add it to the middleware stack in ``config/pipeline.php`` after `$app->pipe(RouteMiddleware::class);` @@ -40,37 +36,34 @@ After registering the package, add it to the middleware stack in ``config/pipeli $app->pipe(RouteMiddleware::class); $app->pipe(\Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware::class); - Create a new file ``response-header.global.php`` in ``config/autoload`` with the below configuration array : -``` - [ - '*' => [ - 'CustomHeader1' => [ - 'value' => 'CustomHeader1-Value', - 'overwrite' => true, + [ + '*' => [ + 'CustomHeader1' => [ + 'value' => 'CustomHeader1-Value', + 'overwrite' => true, + ], + 'CustomHeader2' => [ + 'value' => 'CustomHeader2-Value', + 'overwrite' => false, + ], ], - 'CustomHeader2' => [ - 'value' => 'CustomHeader2-Value', - 'overwrite' => false, + 'home' => [ + 'CustomHeader' => [ + 'value' => 'header3', + ] ], - ], - 'home' => [ - 'CustomHeader' => [ - 'value' => 'header3', - ] - ], - 'login' => [ - 'LoginHeader' => [ - 'value' => 'LoginHeader-Value', - 'overwrite' => false - ] - ], - ] -]; -``` + 'login' => [ + 'LoginHeader' => [ + 'value' => 'LoginHeader-Value', + 'overwrite' => false + ] + ], + ] + ]; Because headers are matched with route names, we can have custom response headers for every request, by defining new headers under the ``*`` key. @@ -78,19 +71,17 @@ All headers under ``*`` will be set for every response. To add response headers for a specific set of routes, define a new array using the route name as the array key. -Example : - -``` -'dot_response_headers' => [ - 'user' => [ - 'UserCustomHeader' => [ - 'value' => 'UserCustomHeader-Value', - 'overwrite' => false - ] - ], -] +Example : -// This will set a new header named UserCustomHeader with the UserCustomHeader-Value value for any route name matching 'user' -``` + 'dot_response_headers' => [ + 'user' => [ + 'UserCustomHeader' => [ + 'value' => 'UserCustomHeader-Value', + 'overwrite' => false + ] + ], + ] + + // This will set a new header named UserCustomHeader with the UserCustomHeader-Value value for any route name matching 'user' To overwrite an existing header use ``overwrite => true``. From 6723cffee0e0a5e9f6f2f5699b6dce06a508fced Mon Sep 17 00:00:00 2001 From: nati Date: Wed, 10 Apr 2024 14:26:08 +0300 Subject: [PATCH 04/11] Fixing CI errors --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d109d8..86d10dc 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "mezzio/mezzio-router": "^3.16", "psr/http-client": "^1.0", - "psr/http-message": "^1.0 || ^2.0" + "psr/http-message": "^2.0" }, "require-dev": { "laminas/laminas-coding-standard": "^2.5", From 1238d5fe2c5805cb0f9c844cd197558f80d874b8 Mon Sep 17 00:00:00 2001 From: nati Date: Wed, 10 Apr 2024 14:28:15 +0300 Subject: [PATCH 05/11] Fixing CI errors --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 86d10dc..26628ad 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "mezzio/mezzio-router": "^3.16", "psr/http-client": "^1.0", - "psr/http-message": "^2.0" + "psr/http-message": "^1.1 || ^2.0" }, "require-dev": { "laminas/laminas-coding-standard": "^2.5", From 4d9a85f97d790054eb1e9ad516091cc1503dc0fb Mon Sep 17 00:00:00 2001 From: nati Date: Wed, 10 Apr 2024 15:35:19 +0300 Subject: [PATCH 06/11] Change psr/http-message from ^1.0 || ^2.0 to ^2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 26628ad..86d10dc 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "mezzio/mezzio-router": "^3.16", "psr/http-client": "^1.0", - "psr/http-message": "^1.1 || ^2.0" + "psr/http-message": "^2.0" }, "require-dev": { "laminas/laminas-coding-standard": "^2.5", From 3cb207d884f01c1e873f48bf5a71f45355b17e51 Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 11 Apr 2024 16:22:43 +0300 Subject: [PATCH 07/11] Fixed mkdocs.yml --- mkdocs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index f979693..c40050c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,10 +8,10 @@ extra: nav: - Home: index.md - v3: - - Overview: v5/overview.md - - Installation: v5/installation.md - - Usage: v5/usage.md - - Factories: v5/factories.md + - Overview: v3/overview.md + - Installation: v3/installation.md + - Usage: v3/usage.md + - Factories: v3/configuration.md site_name: dot-response-header site_description: "DotKernel's middleware for setting and overwriting custom response headers." repo_url: "https://github.com/dotkernel/dot-response-header" From b21a5c9779a8676f4273d3336c30256da3baf775 Mon Sep 17 00:00:00 2001 From: PopNatanael Date: Thu, 11 Apr 2024 16:26:44 +0300 Subject: [PATCH 08/11] Fixed typo in mkdocs --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index c40050c..5d20a0d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -11,7 +11,7 @@ nav: - Overview: v3/overview.md - Installation: v3/installation.md - Usage: v3/usage.md - - Factories: v3/configuration.md + - Configuration: v3/configuration.md site_name: dot-response-header site_description: "DotKernel's middleware for setting and overwriting custom response headers." repo_url: "https://github.com/dotkernel/dot-response-header" From 8c59ed9c8ddd8c48beae947fc582f30fb0b7bd4c Mon Sep 17 00:00:00 2001 From: PopNatanael Date: Fri, 12 Apr 2024 13:37:00 +0300 Subject: [PATCH 09/11] Fixed mkdocs order, README wrong use and missing lines --- .github/workflows/docs-build.yml | 2 +- README.md | 10 +++++----- docs/book/v3/installation.md | 2 +- mkdocs.yml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index f9be9e2..a18edb1 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -13,4 +13,4 @@ jobs: uses: dotkernel/documentation-theme/github-actions/docs@main env: DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 4359a76..03043f7 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,12 @@ Next, register the package's `ConfigProvider` to your application config. Note : Make sure to register the package under the `// DK packages` section. -After registering the package, add it to the middleware stack in ``config/pipeline.php`` after `$app->pipe(RouteMiddleware::class);` +After registering the package, add it to the middleware stack in `config/pipeline.php` after `$app->pipe(RouteMiddleware::class);` $app->pipe(RouteMiddleware::class); $app->pipe(\Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware::class); -Create a new file ``response-header.global.php`` in ``config/autoload`` with the below configuration array : +Create a new file `response-header.global.php` in `config/autoload` with the below configuration array : true``. +To overwrite an existing header use `overwrite => true`. diff --git a/docs/book/v3/installation.md b/docs/book/v3/installation.md index 3bded62..7cdd8e0 100644 --- a/docs/book/v3/installation.md +++ b/docs/book/v3/installation.md @@ -2,4 +2,4 @@ Install dotkernel/dot-response-header by executing the following Composer command in your project directory: - $ composer require dotkernel/dot-response-header + composer require dotkernel/dot-response-header diff --git a/mkdocs.yml b/mkdocs.yml index 5d20a0d..d9f0fae 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,8 +10,8 @@ nav: - v3: - Overview: v3/overview.md - Installation: v3/installation.md - - Usage: v3/usage.md - Configuration: v3/configuration.md + - Usage: v3/usage.md site_name: dot-response-header site_description: "DotKernel's middleware for setting and overwriting custom response headers." repo_url: "https://github.com/dotkernel/dot-response-header" From adfd94e74d23926459cbe1069093eb5b059e9221 Mon Sep 17 00:00:00 2001 From: PopNatanael Date: Tue, 16 Apr 2024 12:21:08 +0300 Subject: [PATCH 10/11] Changed line separators for files --- .github/workflows/continuous-integration.yml | 22 ++-- .github/workflows/docs-build.yml | 32 +++--- docs/book/index.md | 2 +- docs/book/v3/configuration.md | 114 +++++++++---------- docs/book/v3/installation.md | 10 +- docs/book/v3/overview.md | 6 +- docs/book/v3/usage.md | 48 ++++---- 7 files changed, 117 insertions(+), 117 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 72dde2f..26c5802 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,11 +1,11 @@ -name: "Continuous Integration" - -on: - pull_request: - push: - branches: - tags: - -jobs: - ci: - uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x +name: "Continuous Integration" + +on: + pull_request: + push: + branches: + tags: + +jobs: + ci: + uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index a18edb1..1a7aa24 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -1,16 +1,16 @@ -name: docs-build - -on: - release: - types: [published] - workflow_dispatch: - -jobs: - build-deploy: - runs-on: ubuntu-latest - steps: - - name: Build Docs - uses: dotkernel/documentation-theme/github-actions/docs@main - env: - DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +name: docs-build + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build-deploy: + runs-on: ubuntu-latest + steps: + - name: Build Docs + uses: dotkernel/documentation-theme/github-actions/docs@main + env: + DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/book/index.md b/docs/book/index.md index 4c0539a..ae42a26 100644 --- a/docs/book/index.md +++ b/docs/book/index.md @@ -1 +1 @@ -../../README.md +../../README.md diff --git a/docs/book/v3/configuration.md b/docs/book/v3/configuration.md index 330b18b..64c3e9c 100644 --- a/docs/book/v3/configuration.md +++ b/docs/book/v3/configuration.md @@ -1,57 +1,57 @@ -# Configuration - -## Requirements - -- PHP >= 8.1 - -## Register ConfigProvider - -Next, register the package's `ConfigProvider` to your application config. - -```php -Dot\ResponseHeader\ConfigProvider::class, -``` - -Note : Make sure to register the package under the `// DK packages` section. - -## Add the package to the middleware stack - -After registering the package, add it to the middleware stack in `config/pipeline.php` after `$app->pipe(RouteMiddleware::class);` - -```php -$app->pipe(RouteMiddleware::class); -$app->pipe(\Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware::class); -``` - -## Add configuration in autoload - -Create a new file `response-header.global.php` in `config/autoload` with the below configuration array : - -```php - [ - '*' => [ - 'CustomHeader1' => [ - 'value' => 'CustomHeader1-Value', - 'overwrite' => true, - ], - 'CustomHeader2' => [ - 'value' => 'CustomHeader2-Value', - 'overwrite' => false, - ], - ], - 'home' => [ - 'CustomHeader' => [ - 'value' => 'header3', - ] - ], - 'login' => [ - 'LoginHeader' => [ - 'value' => 'LoginHeader-Value', - 'overwrite' => false - ] - ], - ] -]; -``` +# Configuration + +## Requirements + +- PHP >= 8.1 + +## Register ConfigProvider + +Next, register the package's `ConfigProvider` to your application config. + +```php +Dot\ResponseHeader\ConfigProvider::class, +``` + +Note : Make sure to register the package under the `// DK packages` section. + +## Add the package to the middleware stack + +After registering the package, add it to the middleware stack in `config/pipeline.php` after `$app->pipe(RouteMiddleware::class);` + +```php +$app->pipe(RouteMiddleware::class); +$app->pipe(\Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware::class); +``` + +## Add configuration in autoload + +Create a new file `response-header.global.php` in `config/autoload` with the below configuration array : + +```php + [ + '*' => [ + 'CustomHeader1' => [ + 'value' => 'CustomHeader1-Value', + 'overwrite' => true, + ], + 'CustomHeader2' => [ + 'value' => 'CustomHeader2-Value', + 'overwrite' => false, + ], + ], + 'home' => [ + 'CustomHeader' => [ + 'value' => 'header3', + ] + ], + 'login' => [ + 'LoginHeader' => [ + 'value' => 'LoginHeader-Value', + 'overwrite' => false + ] + ], + ] +]; +``` diff --git a/docs/book/v3/installation.md b/docs/book/v3/installation.md index 7cdd8e0..a1a5edb 100644 --- a/docs/book/v3/installation.md +++ b/docs/book/v3/installation.md @@ -1,5 +1,5 @@ -# Installation - -Install dotkernel/dot-response-header by executing the following Composer command in your project directory: - - composer require dotkernel/dot-response-header +# Installation + +Install dotkernel/dot-response-header by executing the following Composer command in your project directory: + + composer require dotkernel/dot-response-header diff --git a/docs/book/v3/overview.md b/docs/book/v3/overview.md index d57c953..56a80cc 100644 --- a/docs/book/v3/overview.md +++ b/docs/book/v3/overview.md @@ -1,3 +1,3 @@ -# Overview - -`dot-response-header` is DotKernel's middleware for setting and overwriting custom response headers. +# Overview + +`dot-response-header` is DotKernel's middleware for setting and overwriting custom response headers. diff --git a/docs/book/v3/usage.md b/docs/book/v3/usage.md index 3e5f8d7..131fe86 100644 --- a/docs/book/v3/usage.md +++ b/docs/book/v3/usage.md @@ -1,24 +1,24 @@ -# Usage - -Because headers are matched with route names, we can have custom response headers for every request, by defining new headers under the `*` key, in the configuration file `response-header.global.php`. - -All headers under `*` will be set for every response. - -To add response headers for a specific set of routes, define a new array using the route name as the array key. - -## Example - -```php -'dot_response_headers' => [ - 'user' => [ - 'UserCustomHeader' => [ - 'value' => 'UserCustomHeader-Value', - 'overwrite' => false - ] - ], -] - -// This will set a new header named UserCustomHeader with the UserCustomHeader-Value value for any route name matching 'user' -``` - -To overwrite an existing header use `overwrite => true`. +# Usage + +Because headers are matched with route names, we can have custom response headers for every request, by defining new headers under the `*` key, in the configuration file `response-header.global.php`. + +All headers under `*` will be set for every response. + +To add response headers for a specific set of routes, define a new array using the route name as the array key. + +## Example + +```php +'dot_response_headers' => [ + 'user' => [ + 'UserCustomHeader' => [ + 'value' => 'UserCustomHeader-Value', + 'overwrite' => false + ] + ], +] + +// This will set a new header named UserCustomHeader with the UserCustomHeader-Value value for any route name matching 'user' +``` + +To overwrite an existing header use `overwrite => true`. From 260b7416d95f447a913e0afad67370ac02805e35 Mon Sep 17 00:00:00 2001 From: PopNatanael Date: Tue, 23 Apr 2024 12:41:14 +0300 Subject: [PATCH 11/11] Replaced static-analysis.yml with continuous-integration.yml in static badge and added unsupported version in SECURITY --- README.md | 2 +- SECURITY.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03043f7..ca61a51 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-response-header)](https://github.com/dotkernel/dot-response-header/stargazers) [![GitHub license](https://img.shields.io/github/license/dotkernel/dot-response-header)](https://github.com/dotkernel/dot-response-header/blob/3.0/LICENSE) -[![Build Static](https://github.com/dotkernel/dot-response-header/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-response-header/actions/workflows/static-analysis.yml) +[![Build Static](https://github.com/dotkernel/dot-response-header/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-response-header/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-response-header/graph/badge.svg?token=NNRZN0FBF2)](https://codecov.io/gh/dotkernel/dot-response-header) [![SymfonyInsight](https://insight.symfony.com/projects/dce88959-bd29-40ef-b1e7-d12815145438/big.svg)](https://insight.symfony.com/projects/dce88959-bd29-40ef-b1e7-d12815145438) diff --git a/SECURITY.md b/SECURITY.md index 049f4a0..45e86c9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,6 +6,9 @@ | Version | Supported | PHP Version | |---------|--------------------|---------------------------------------------------------------------------------------------------------------------| | 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-response-header/3.2.3) | +| <= 2.x | :x: | | + + ## Reporting Potential Security Issues