From daeef4fe0adfc3d46edf5d278b096209a3388152 Mon Sep 17 00:00:00 2001 From: Eric Fortmeyer Date: Sun, 21 May 2023 00:52:39 -0500 Subject: [PATCH] fix: inject the token into the middleware The response filter and the token storage require access to the token. BREAKING CHANGE: Inject the token into the `CsrfResponseFilterMiddleware`'s constructor. The `CsrfTokenGenerator` has been removed. --- README.md | 2 +- acceptance-test-results.md | 2 +- ...ion-Http-CsrfResponseFilterMiddleware.html | 14 ++++---- docs/graphs/classes.svg | 12 +++---- docs/indices/files.html | 1 - docs/js/searchIndex.js | 15 --------- docs/namespaces/phpolar-csrfprotection.html | 3 -- docs/packages/Phpolar-CsrfProtection.html | 3 -- phpunit.dev.xml | 2 +- src/CsrfTokenGenerator.php | 26 --------------- src/Http/CsrfResponseFilterMiddleware.php | 13 ++++---- tests/acceptance/MemoryUsageTest.php | 2 +- tests/unit/CsrfTokenGeneratorTest.php | 32 ------------------- .../Http/CsrfResponseFilterMiddlewareTest.php | 4 +-- 14 files changed, 23 insertions(+), 108 deletions(-) delete mode 100644 src/CsrfTokenGenerator.php delete mode 100644 tests/unit/CsrfTokenGeneratorTest.php diff --git a/README.md b/README.md index 8de1791..d515bee 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,6 @@ $preparedResponse = $middleWare->process($request, $routingHandler); ## Thresholds |Source Code Size|Memory Usage| |----------------|------------| -|4.5 kB|108 kB +|4.2 kB|108 kB [Back to top](#csrf-protection) diff --git a/acceptance-test-results.md b/acceptance-test-results.md index 5c98518..455ed0b 100644 --- a/acceptance-test-results.md +++ b/acceptance-test-results.md @@ -23,5 +23,5 @@ - [x] Memory usage shall be below 108000 bytes ## Project Size (Phpolar\CsrfProtection\ProjectSize) -- [x] Source code total size shall be below 4500 bytes +- [x] Source code total size shall be below 4200 bytes diff --git a/docs/classes/Phpolar-CsrfProtection-Http-CsrfResponseFilterMiddleware.html b/docs/classes/Phpolar-CsrfProtection-Http-CsrfResponseFilterMiddleware.html index aab5a5b..42f5152 100644 --- a/docs/classes/Phpolar-CsrfProtection-Http-CsrfResponseFilterMiddleware.html +++ b/docs/classes/Phpolar-CsrfProtection-Http-CsrfResponseFilterMiddleware.html @@ -206,31 +206,31 @@

public - __construct(AbstractTokenStorage $storage, CsrfTokenGenerator $tokenGenerator, ResponseFilterStrategyInterface $filterStrategy) : mixed + __construct(CsrfToken $token, AbstractTokenStorage $storage, ResponseFilterInterface $responseFilter) : mixed

Parameters
- $storage - : AbstractTokenStorage + $token + : CsrfToken
- $tokenGenerator - : CsrfTokenGenerator + $storage + : AbstractTokenStorage
- $filterStrategy - : ResponseFilterStrategyInterface + $responseFilter + : ResponseFilterInterface
diff --git a/docs/graphs/classes.svg b/docs/graphs/classes.svg index 1750010..7eb379a 100644 --- a/docs/graphs/classes.svg +++ b/docs/graphs/classes.svg @@ -1,10 +1,9 @@ -Phpolar\CsrfProtectionPhpolar\CsrfProtectionPhpolar\CsrfProtection\HttpPsr\Http\ServerPhpolar\CsrfProtection\StorageCsrfTokenCsrfTokenGeneratorCsrfTokenCsrfProtectionRequestHandlerCsrfRequestCheckMiddlewareCsrfResponseFilterMiddleware