diff --git a/CHANGELOG.md b/CHANGELOG.md index 95868c2..b5c1853 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - All authenticators now return an `Innmind\Immutable\Attempt` - All authenticators can return any type inside the `Attempt` +- Requires `innmind/foundation:~1.9` ### Removed diff --git a/composer.json b/composer.json index 79324d7..15532dc 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,7 @@ }, "require": { "php": "~8.2", - "innmind/immutable": "~5.18", - "innmind/http": "~7.0" + "innmind/foundation": "~1.9" }, "autoload": { "psr-4": { diff --git a/src/ViaAuthorization.php b/src/ViaAuthorization.php index 4374121..dc3a4df 100644 --- a/src/ViaAuthorization.php +++ b/src/ViaAuthorization.php @@ -6,23 +6,19 @@ use Innmind\Http\{ ServerRequest, Header\Authorization, - Header\AuthorizationValue, -}; -use Innmind\Immutable\{ - Attempt, - Predicate\Instance, }; +use Innmind\Immutable\Attempt; /** * @template T */ final class ViaAuthorization { - /** @var callable(AuthorizationValue): Attempt */ + /** @var callable(Authorization): Attempt */ private $resolve; /** - * @param callable(AuthorizationValue): Attempt $resolve + * @param callable(Authorization): Attempt $resolve */ public function __construct(callable $resolve) { @@ -37,8 +33,6 @@ public function __invoke(ServerRequest $request): Attempt return $request ->headers() ->find(Authorization::class) - ->flatMap(static fn($header) => $header->values()->find(static fn() => true)) - ->keep(Instance::of(AuthorizationValue::class)) ->attempt(static fn() => new \RuntimeException('Failed to resolve identity')) ->flatMap(fn($value) => ($this->resolve)($value)); } diff --git a/tests/ViaAuthorizationTest.php b/tests/ViaAuthorizationTest.php index 92b0d9f..a892b7b 100644 --- a/tests/ViaAuthorizationTest.php +++ b/tests/ViaAuthorizationTest.php @@ -9,10 +9,9 @@ Method, ProtocolVersion, Headers, - Header\Header, - Header\Value\Value, + Header, + Header\Value, Header\Authorization, - Header\AuthorizationValue, }; use Innmind\Url\Url; use Innmind\Immutable\Attempt; @@ -47,7 +46,7 @@ public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly() Method::get, ProtocolVersion::v11, Headers::of( - new Header('Authorization', new Value('Basic foo')), + Header::of('Authorization', Value::of('Basic foo')), ), ); @@ -62,13 +61,13 @@ public function testInvokation() $authenticate = new ViaAuthorization( static fn($value) => Attempt::result($value), ); - $expected = new AuthorizationValue('Bearer', 'foo'); + $expected = Authorization::of('Bearer', 'foo'); $request = ServerRequest::of( Url::of('/'), Method::get, ProtocolVersion::v11, Headers::of( - new Authorization($expected), + $expected, ), ); diff --git a/tests/ViaBasicAuthorizationTest.php b/tests/ViaBasicAuthorizationTest.php index 68798f5..884ddb8 100644 --- a/tests/ViaBasicAuthorizationTest.php +++ b/tests/ViaBasicAuthorizationTest.php @@ -9,8 +9,8 @@ Method, ProtocolVersion, Headers, - Header\Header, - Header\Value\Value, + Header, + Header\Value, Header\Authorization, }; use Innmind\Url\Url; @@ -46,7 +46,7 @@ public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly() Method::get, ProtocolVersion::v11, Headers::of( - new Header('Authorization', new Value('Basic foo')), + Header::of('Authorization', Value::of('Basic foo')), ), );