From d3ed4144657aee6ecbad39a45c234659d1cac7fd Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 24 Aug 2025 16:05:26 +0200 Subject: [PATCH 1/7] replace all resolvers by callables --- CHANGELOG.md | 5 ++- src/ViaAuthorization.php | 9 +++-- src/ViaAuthorization/NullResolver.php | 17 ---------- src/ViaAuthorization/Resolver.php | 16 --------- src/ViaBasicAuthorization.php | 9 +++-- src/ViaBasicAuthorization/NullResolver.php | 16 --------- src/ViaBasicAuthorization/Resolver.php | 15 --------- src/ViaForm.php | 10 ++++-- src/ViaForm/NullResolver.php | 17 ---------- src/ViaForm/Resolver.php | 16 --------- src/ViaUrlAuthority.php | 9 +++-- src/ViaUrlAuthority/NullResolver.php | 20 ----------- src/ViaUrlAuthority/Resolver.php | 19 ----------- tests/ViaAuthorization/NullResolverTest.php | 27 --------------- tests/ViaAuthorizationTest.php | 22 +++---------- .../NullResolverTest.php | 26 --------------- tests/ViaBasicAuthorizationTest.php | 27 ++++----------- tests/ViaForm/NullResolverTest.php | 27 --------------- tests/ViaFormTest.php | 17 +++------- tests/ViaUrlAuthority/NullResolverTest.php | 33 ------------------- tests/ViaUrlAuthorityTest.php | 17 +++------- 21 files changed, 48 insertions(+), 326 deletions(-) delete mode 100644 src/ViaAuthorization/NullResolver.php delete mode 100644 src/ViaAuthorization/Resolver.php delete mode 100644 src/ViaBasicAuthorization/NullResolver.php delete mode 100644 src/ViaBasicAuthorization/Resolver.php delete mode 100644 src/ViaForm/NullResolver.php delete mode 100644 src/ViaForm/Resolver.php delete mode 100644 src/ViaUrlAuthority/NullResolver.php delete mode 100644 src/ViaUrlAuthority/Resolver.php delete mode 100644 tests/ViaAuthorization/NullResolverTest.php delete mode 100644 tests/ViaBasicAuthorization/NullResolverTest.php delete mode 100644 tests/ViaForm/NullResolverTest.php delete mode 100644 tests/ViaUrlAuthority/NullResolverTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index ad3bea0..d7eba38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,10 @@ ### Changed - `Innmind\HttpAuthentication\Authenticator::__invoke()` now returns an `Innmind\Immutable\Attempt` -- All resolvers now return an `Innmind\Immutable\Attempt` + +### Removed + +- All resolvers have been replaced by `callable`s ## 4.0.0 - 2023-11-01 diff --git a/src/ViaAuthorization.php b/src/ViaAuthorization.php index 838c881..8a2a484 100644 --- a/src/ViaAuthorization.php +++ b/src/ViaAuthorization.php @@ -3,7 +3,6 @@ namespace Innmind\HttpAuthentication; -use Innmind\HttpAuthentication\ViaAuthorization\Resolver; use Innmind\Http\{ ServerRequest, Header\Authorization, @@ -16,9 +15,13 @@ final class ViaAuthorization implements Authenticator { - private Resolver $resolve; + /** @var callable(AuthorizationValue): Attempt */ + private $resolve; - public function __construct(Resolver $resolve) + /** + * @param callable(AuthorizationValue): Attempt $resolve + */ + public function __construct(callable $resolve) { $this->resolve = $resolve; } diff --git a/src/ViaAuthorization/NullResolver.php b/src/ViaAuthorization/NullResolver.php deleted file mode 100644 index b7d2497..0000000 --- a/src/ViaAuthorization/NullResolver.php +++ /dev/null @@ -1,17 +0,0 @@ - */ - return Attempt::error(new \LogicException('Not implemented')); - } -} diff --git a/src/ViaAuthorization/Resolver.php b/src/ViaAuthorization/Resolver.php deleted file mode 100644 index c5135ca..0000000 --- a/src/ViaAuthorization/Resolver.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function __invoke(AuthorizationValue $value): Attempt; -} diff --git a/src/ViaBasicAuthorization.php b/src/ViaBasicAuthorization.php index 003c2b3..dbe305e 100644 --- a/src/ViaBasicAuthorization.php +++ b/src/ViaBasicAuthorization.php @@ -3,7 +3,6 @@ namespace Innmind\HttpAuthentication; -use Innmind\HttpAuthentication\ViaBasicAuthorization\Resolver; use Innmind\Http\{ ServerRequest, Header\Authorization, @@ -12,9 +11,13 @@ final class ViaBasicAuthorization implements Authenticator { - private Resolver $resolve; + /** @var callable(string, string): Attempt */ + private $resolve; - public function __construct(Resolver $resolve) + /** + * @param callable(string, string): Attempt $resolve + */ + public function __construct(callable $resolve) { $this->resolve = $resolve; } diff --git a/src/ViaBasicAuthorization/NullResolver.php b/src/ViaBasicAuthorization/NullResolver.php deleted file mode 100644 index 9ee4c15..0000000 --- a/src/ViaBasicAuthorization/NullResolver.php +++ /dev/null @@ -1,16 +0,0 @@ - */ - return Attempt::error(new \LogicException('Not implemented')); - } -} diff --git a/src/ViaBasicAuthorization/Resolver.php b/src/ViaBasicAuthorization/Resolver.php deleted file mode 100644 index d5ac2fb..0000000 --- a/src/ViaBasicAuthorization/Resolver.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ - public function __invoke(string $user, string $password): Attempt; -} diff --git a/src/ViaForm.php b/src/ViaForm.php index 1311ddd..9462654 100644 --- a/src/ViaForm.php +++ b/src/ViaForm.php @@ -3,9 +3,9 @@ namespace Innmind\HttpAuthentication; -use Innmind\HttpAuthentication\ViaForm\Resolver; use Innmind\Http\{ ServerRequest, + ServerRequest\Form, Method, }; use Innmind\Immutable\{ @@ -15,9 +15,13 @@ final class ViaForm implements Authenticator { - private Resolver $resolve; + /** @var callable(Form): Attempt */ + private $resolve; - public function __construct(Resolver $resolve) + /** + * @param callable(Form): Attempt $resolve + */ + public function __construct(callable $resolve) { $this->resolve = $resolve; } diff --git a/src/ViaForm/NullResolver.php b/src/ViaForm/NullResolver.php deleted file mode 100644 index 251f6a2..0000000 --- a/src/ViaForm/NullResolver.php +++ /dev/null @@ -1,17 +0,0 @@ - */ - return Attempt::error(new \LogicException('Not implemented')); - } -} diff --git a/src/ViaForm/Resolver.php b/src/ViaForm/Resolver.php deleted file mode 100644 index 82110b2..0000000 --- a/src/ViaForm/Resolver.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function __invoke(Form $form): Attempt; -} diff --git a/src/ViaUrlAuthority.php b/src/ViaUrlAuthority.php index 29b8e25..29962ae 100644 --- a/src/ViaUrlAuthority.php +++ b/src/ViaUrlAuthority.php @@ -3,7 +3,6 @@ namespace Innmind\HttpAuthentication; -use Innmind\HttpAuthentication\ViaUrlAuthority\Resolver; use Innmind\Http\ServerRequest; use Innmind\Url\Authority\UserInformation\{ User, @@ -13,9 +12,13 @@ final class ViaUrlAuthority implements Authenticator { - private Resolver $resolve; + /** @var callable(User, Password): Attempt */ + private $resolve; - public function __construct(Resolver $resolve) + /** + * @param callable(User, Password): Attempt $resolve + */ + public function __construct(callable $resolve) { $this->resolve = $resolve; } diff --git a/src/ViaUrlAuthority/NullResolver.php b/src/ViaUrlAuthority/NullResolver.php deleted file mode 100644 index e3e5014..0000000 --- a/src/ViaUrlAuthority/NullResolver.php +++ /dev/null @@ -1,20 +0,0 @@ - */ - return Attempt::error(new \LogicException('Not implemented')); - } -} diff --git a/src/ViaUrlAuthority/Resolver.php b/src/ViaUrlAuthority/Resolver.php deleted file mode 100644 index 6748d0f..0000000 --- a/src/ViaUrlAuthority/Resolver.php +++ /dev/null @@ -1,19 +0,0 @@ - - */ - public function __invoke(User $user, Password $password): Attempt; -} diff --git a/tests/ViaAuthorization/NullResolverTest.php b/tests/ViaAuthorization/NullResolverTest.php deleted file mode 100644 index e101105..0000000 --- a/tests/ViaAuthorization/NullResolverTest.php +++ /dev/null @@ -1,27 +0,0 @@ -assertInstanceOf(Resolver::class, new NullResolver); - } - - public function testInvokation() - { - $this->assertNull((new NullResolver)(new AuthorizationValue('Bearer', 'foo'))->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} diff --git a/tests/ViaAuthorizationTest.php b/tests/ViaAuthorizationTest.php index 7e55a8e..245a6bb 100644 --- a/tests/ViaAuthorizationTest.php +++ b/tests/ViaAuthorizationTest.php @@ -5,8 +5,6 @@ use Innmind\HttpAuthentication\{ ViaAuthorization, - ViaAuthorization\Resolver, - ViaAuthorization\NullResolver, Authenticator, Identity, }; @@ -30,18 +28,15 @@ public function testInterface() { $this->assertInstanceOf( Authenticator::class, - new ViaAuthorization(new NullResolver), + new ViaAuthorization(static fn() => null), ); } public function testReturnNothingWhenNoAuthorizationHeader() { $authenticate = new ViaAuthorization( - $resolver = $this->createMock(Resolver::class), + static fn() => throw new \Exception, ); - $resolver - ->expects($this->never()) - ->method('__invoke'); $request = ServerRequest::of( Url::of('/'), Method::get, @@ -57,11 +52,8 @@ public function testReturnNothingWhenNoAuthorizationHeader() public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly() { $authenticate = new ViaAuthorization( - $resolver = $this->createMock(Resolver::class), + static fn() => throw new \Exception, ); - $resolver - ->expects($this->never()) - ->method('__invoke'); $request = ServerRequest::of( Url::of('/'), Method::get, @@ -79,15 +71,11 @@ public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly() public function testInvokation() { + $identity = $this->createMock(Identity::class); $authenticate = new ViaAuthorization( - $resolver = $this->createMock(Resolver::class), + static fn() => Attempt::result($identity), ); $expected = new AuthorizationValue('Bearer', 'foo'); - $resolver - ->expects($this->once()) - ->method('__invoke') - ->with($expected) - ->willReturn(Attempt::result($identity = $this->createMock(Identity::class))); $request = ServerRequest::of( Url::of('/'), Method::get, diff --git a/tests/ViaBasicAuthorization/NullResolverTest.php b/tests/ViaBasicAuthorization/NullResolverTest.php deleted file mode 100644 index fc50b0b..0000000 --- a/tests/ViaBasicAuthorization/NullResolverTest.php +++ /dev/null @@ -1,26 +0,0 @@ -assertInstanceOf(Resolver::class, new NullResolver); - } - - public function testInvokation() - { - $this->assertNull((new NullResolver)('user', 'password')->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} diff --git a/tests/ViaBasicAuthorizationTest.php b/tests/ViaBasicAuthorizationTest.php index 439bac8..a5288d7 100644 --- a/tests/ViaBasicAuthorizationTest.php +++ b/tests/ViaBasicAuthorizationTest.php @@ -5,8 +5,6 @@ use Innmind\HttpAuthentication\{ ViaBasicAuthorization, - ViaBasicAuthorization\Resolver, - ViaBasicAuthorization\NullResolver, Authenticator, Identity, }; @@ -29,18 +27,15 @@ public function testInterface() { $this->assertInstanceOf( Authenticator::class, - new ViaBasicAuthorization(new NullResolver), + new ViaBasicAuthorization(static fn() => null), ); } public function testReturnNothingWhenNoAuthorizationHeader() { $authenticate = new ViaBasicAuthorization( - $resolver = $this->createMock(Resolver::class), + static fn() => throw new \Exception, ); - $resolver - ->expects($this->never()) - ->method('__invoke'); $request = ServerRequest::of( Url::of('/'), Method::get, @@ -56,11 +51,8 @@ public function testReturnNothingWhenNoAuthorizationHeader() public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly() { $authenticate = new ViaBasicAuthorization( - $resolver = $this->createMock(Resolver::class), + static fn() => throw new \Exception, ); - $resolver - ->expects($this->never()) - ->method('__invoke'); $request = ServerRequest::of( Url::of('/'), Method::get, @@ -79,11 +71,8 @@ public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly() public function testReturnNothingWhenNotBasicAuthorization() { $authenticate = new ViaBasicAuthorization( - $resolver = $this->createMock(Resolver::class), + static fn() => throw new \Exception, ); - $resolver - ->expects($this->never()) - ->method('__invoke'); $request = ServerRequest::of( Url::of('/'), Method::get, @@ -101,14 +90,10 @@ public function testReturnNothingWhenNotBasicAuthorization() public function testInvokation() { + $identity = $this->createMock(Identity::class); $authenticate = new ViaBasicAuthorization( - $resolver = $this->createMock(Resolver::class), + static fn() => Attempt::result($identity), ); - $resolver - ->expects($this->once()) - ->method('__invoke') - ->with('foo', 'bar') - ->willReturn(Attempt::result($identity = $this->createMock(Identity::class))); $request = ServerRequest::of( Url::of('/'), Method::get, diff --git a/tests/ViaForm/NullResolverTest.php b/tests/ViaForm/NullResolverTest.php deleted file mode 100644 index 2da9adc..0000000 --- a/tests/ViaForm/NullResolverTest.php +++ /dev/null @@ -1,27 +0,0 @@ -assertInstanceOf(Resolver::class, new NullResolver); - } - - public function testInvokation() - { - $this->assertNull((new NullResolver)(Form::of([]))->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} diff --git a/tests/ViaFormTest.php b/tests/ViaFormTest.php index d725dae..7f4e517 100644 --- a/tests/ViaFormTest.php +++ b/tests/ViaFormTest.php @@ -6,8 +6,6 @@ use Innmind\HttpAuthentication\{ ViaForm, Authenticator, - ViaForm\Resolver, - ViaForm\NullResolver, Identity, }; use Innmind\Http\{ @@ -25,18 +23,15 @@ public function testInterface() { $this->assertInstanceOf( Authenticator::class, - new ViaForm(new NullResolver), + new ViaForm(static fn() => null), ); } public function testReturnNothingWhenNotPostRequest() { $authenticate = new ViaForm( - $resolver = $this->createMock(Resolver::class), + static fn() => throw new \Exception, ); - $resolver - ->expects($this->never()) - ->method('__invoke'); $request = ServerRequest::of( Url::of('/'), Method::get, @@ -51,19 +46,15 @@ public function testReturnNothingWhenNotPostRequest() public function testInvokation() { + $identity = $this->createMock(Identity::class); $authenticate = new ViaForm( - $resolver = $this->createMock(Resolver::class), + static fn() => Attempt::result($identity), ); $request = ServerRequest::of( Url::of('/'), Method::post, ProtocolVersion::v11, ); - $resolver - ->expects($this->once()) - ->method('__invoke') - ->with($request->form()) - ->willReturn(Attempt::result($identity = $this->createMock(Identity::class))); $this->assertSame($identity, $authenticate($request)->match( static fn($identity) => $identity, diff --git a/tests/ViaUrlAuthority/NullResolverTest.php b/tests/ViaUrlAuthority/NullResolverTest.php deleted file mode 100644 index 26e54db..0000000 --- a/tests/ViaUrlAuthority/NullResolverTest.php +++ /dev/null @@ -1,33 +0,0 @@ -assertInstanceOf(Resolver::class, new NullResolver); - } - - public function testInvokation() - { - $this->assertNull((new NullResolver)( - User::none(), - Password::none(), - )->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} diff --git a/tests/ViaUrlAuthorityTest.php b/tests/ViaUrlAuthorityTest.php index 1dba920..3322eeb 100644 --- a/tests/ViaUrlAuthorityTest.php +++ b/tests/ViaUrlAuthorityTest.php @@ -6,8 +6,6 @@ use Innmind\HttpAuthentication\{ ViaUrlAuthority, Authenticator, - ViaUrlAuthority\Resolver, - ViaUrlAuthority\NullResolver, Identity, }; use Innmind\Url\Url; @@ -25,19 +23,16 @@ public function testInterface() { $this->assertInstanceOf( Authenticator::class, - new ViaUrlAuthority(new NullResolver), + new ViaUrlAuthority(static fn() => null), ); } public function testReturnNothingWhenNoUserProvidedInTheUrl() { $authenticate = new ViaUrlAuthority( - $resolver = $this->createMock(Resolver::class), + static fn() => throw new \Exception, ); $url = Url::of('https://localhost/'); - $resolver - ->expects($this->never()) - ->method('__invoke'); $request = ServerRequest::of( $url, Method::get, @@ -52,17 +47,13 @@ public function testReturnNothingWhenNoUserProvidedInTheUrl() public function testInvokation() { + $identity = $this->createMock(Identity::class); $authenticate = new ViaUrlAuthority( - $resolver = $this->createMock(Resolver::class), + static fn() => Attempt::result($identity), ); $url = Url::of('https://user:password@localhost/'); $user = $url->authority()->userInformation()->user(); $password = $url->authority()->userInformation()->password(); - $resolver - ->expects($this->once()) - ->method('__invoke') - ->with($user, $password) - ->willReturn(Attempt::result($identity = $this->createMock(Identity::class))); $request = ServerRequest::of( $url, Method::get, From 69ed7b93b0c8c1dd5ae6c90750c5aa42b2987769 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 24 Aug 2025 16:09:41 +0200 Subject: [PATCH 2/7] remove ViaStorage --- CHANGELOG.md | 1 + src/ViaStorage.php | 37 ------------ src/ViaStorage/InMemory.php | 32 ---------- src/ViaStorage/NullStorage.php | 22 ------- src/ViaStorage/Storage.php | 17 ------ tests/ViaStorage/InMemoryTest.php | 76 ------------------------ tests/ViaStorage/NullStorageTest.php | 79 ------------------------- tests/ViaStorageTest.php | 88 ---------------------------- 8 files changed, 1 insertion(+), 351 deletions(-) delete mode 100644 src/ViaStorage.php delete mode 100644 src/ViaStorage/InMemory.php delete mode 100644 src/ViaStorage/NullStorage.php delete mode 100644 src/ViaStorage/Storage.php delete mode 100644 tests/ViaStorage/InMemoryTest.php delete mode 100644 tests/ViaStorage/NullStorageTest.php delete mode 100644 tests/ViaStorageTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index d7eba38..83c5ae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Removed - All resolvers have been replaced by `callable`s +- `Innmind\HttpAuthentication\ViaStorage` ## 4.0.0 - 2023-11-01 diff --git a/src/ViaStorage.php b/src/ViaStorage.php deleted file mode 100644 index 5015b87..0000000 --- a/src/ViaStorage.php +++ /dev/null @@ -1,37 +0,0 @@ -authenticate = $authenticate; - $this->storage = $storage; - } - - public function __invoke(ServerRequest $request): Attempt - { - return $this - ->storage - ->get($request) - ->attempt(static fn() => new \RuntimeException('Identity not in storage')) - ->recover( - fn() => ($this->authenticate)($request)->map( - function($identity) use ($request) { - $this->storage->set($request, $identity); - - return $identity; - }, - ), - ); - } -} diff --git a/src/ViaStorage/InMemory.php b/src/ViaStorage/InMemory.php deleted file mode 100644 index 6a40efc..0000000 --- a/src/ViaStorage/InMemory.php +++ /dev/null @@ -1,32 +0,0 @@ - */ - private Map $identities; - - public function __construct() - { - $this->identities = Map::of(); - } - - public function get(ServerRequest $request): Maybe - { - return $this->identities->get($request); - } - - public function set(ServerRequest $request, Identity $identity): void - { - $this->identities = ($this->identities)($request, $identity); - } -} diff --git a/src/ViaStorage/NullStorage.php b/src/ViaStorage/NullStorage.php deleted file mode 100644 index 8e0676d..0000000 --- a/src/ViaStorage/NullStorage.php +++ /dev/null @@ -1,22 +0,0 @@ - */ - return Maybe::nothing(); - } - - public function set(ServerRequest $request, Identity $identity): void - { - // pass - } -} diff --git a/src/ViaStorage/Storage.php b/src/ViaStorage/Storage.php deleted file mode 100644 index 7becdaf..0000000 --- a/src/ViaStorage/Storage.php +++ /dev/null @@ -1,17 +0,0 @@ - - */ - public function get(ServerRequest $request): Maybe; - public function set(ServerRequest $request, Identity $identity): void; -} diff --git a/tests/ViaStorage/InMemoryTest.php b/tests/ViaStorage/InMemoryTest.php deleted file mode 100644 index 2cd2b79..0000000 --- a/tests/ViaStorage/InMemoryTest.php +++ /dev/null @@ -1,76 +0,0 @@ -assertInstanceOf(Storage::class, new InMemory); - } - - public function testGet() - { - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - - $this->assertNull((new InMemory)->get($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } - - public function testHas() - { - $storage = new InMemory; - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - - $this->assertFalse($storage->get($request)->match( - static fn() => true, - static fn() => false, - )); - $storage->set($request, $this->createMock(Identity::class)); - $this->assertTrue($storage->get($request)->match( - static fn() => true, - static fn() => false, - )); - } - - public function testSet() - { - $storage = new InMemory; - $identity = $this->createMock(Identity::class); - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - - $this->assertNull($storage->set($request, $identity)); - $this->assertSame($identity, $storage->get($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} diff --git a/tests/ViaStorage/NullStorageTest.php b/tests/ViaStorage/NullStorageTest.php deleted file mode 100644 index aed953f..0000000 --- a/tests/ViaStorage/NullStorageTest.php +++ /dev/null @@ -1,79 +0,0 @@ -assertInstanceOf(Storage::class, new NullStorage); - } - - public function testGet() - { - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - - $this->assertNull((new NullStorage)->get($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } - - public function testHas() - { - $storage = new NullStorage; - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - - $this->assertFalse($storage->get($request)->match( - static fn() => true, - static fn() => false, - )); - $storage->set($request, $this->createMock(Identity::class)); - $this->assertFalse($storage->get($request)->match( - static fn() => true, - static fn() => false, - )); - } - - public function testSet() - { - $storage = new NullStorage; - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - - $this->assertNull($storage->set( - $request, - $this->createMock(Identity::class), - )); - - $this->assertNull($storage->get($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} diff --git a/tests/ViaStorageTest.php b/tests/ViaStorageTest.php deleted file mode 100644 index 3d348df..0000000 --- a/tests/ViaStorageTest.php +++ /dev/null @@ -1,88 +0,0 @@ -assertInstanceOf( - Authenticator::class, - new ViaStorage( - $this->createMock(Authenticator::class), - new InMemory, - ), - ); - } - - public function testAuthenticateViaInnerAuthenticator() - { - $authenticate = new ViaStorage( - $inner = $this->createMock(Authenticator::class), - $storage = new InMemory, - ); - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - $inner - ->expects($this->once()) - ->method('__invoke') - ->with($request) - ->willReturn(Attempt::result($identity = $this->createMock(Identity::class))); - - $this->assertSame($identity, $authenticate($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - $this->assertTrue($storage->get($request)->match( - static fn() => true, - static fn() => false, - )); - // second time is to make sure it uses the storage - $this->assertSame($identity, $authenticate($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } - - public function testAuthenticateViaStorage() - { - $authenticate = new ViaStorage( - $inner = $this->createMock(Authenticator::class), - $storage = new InMemory, - ); - $identity = $this->createMock(Identity::class); - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - $inner - ->expects($this->never()) - ->method('__invoke'); - $storage->set($request, $identity); - - $this->assertSame($identity, $authenticate($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} From 7c32d2ec3cb5d953e6818b625b1d481c280c1cdf Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 24 Aug 2025 16:10:36 +0200 Subject: [PATCH 3/7] remove Any --- CHANGELOG.md | 1 + src/Any.php | 35 --------------------- tests/AnyTest.php | 78 ----------------------------------------------- 3 files changed, 1 insertion(+), 113 deletions(-) delete mode 100644 src/Any.php delete mode 100644 tests/AnyTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 83c5ae8..91c5cc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - All resolvers have been replaced by `callable`s - `Innmind\HttpAuthentication\ViaStorage` +- `Innmind\HttpAuthentication\Any` ## 4.0.0 - 2023-11-01 diff --git a/src/Any.php b/src/Any.php deleted file mode 100644 index fb36908..0000000 --- a/src/Any.php +++ /dev/null @@ -1,35 +0,0 @@ - */ - private Sequence $authenticators; - - /** - * @no-named-arguments - */ - public function __construct(Authenticator ...$authenticators) - { - $this->authenticators = Sequence::of(...$authenticators); - } - - public function __invoke(ServerRequest $request): Attempt - { - /** @var Attempt */ - return $this->authenticators->reduce( - Attempt::error(new \LogicException('No authenticator defined')), - static fn(Attempt $identity, $authenticate) => $identity->recover( - static fn() => $authenticate($request), - ), - ); - } -} diff --git a/tests/AnyTest.php b/tests/AnyTest.php deleted file mode 100644 index 826d02b..0000000 --- a/tests/AnyTest.php +++ /dev/null @@ -1,78 +0,0 @@ -assertInstanceOf(Authenticator::class, new Any); - } - - public function testReturnNothingWhenNoAuthenticationProvided() - { - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - - $this->assertNull((new Any)($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } - - public function testInvokation() - { - $authenticate = new Any( - $notSupported = $this->createMock(Authenticator::class), - $notImplemented = $this->createMock(Authenticator::class), - $expected = $this->createMock(Authenticator::class), - $notCalled = $this->createMock(Authenticator::class), - ); - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - $notSupported - ->expects($this->once()) - ->method('__invoke') - ->with($request) - ->willReturn(Attempt::error(new \Exception)); - $notImplemented - ->expects($this->once()) - ->method('__invoke') - ->with($request) - ->willReturn(Attempt::error(new \Exception)); - $expected - ->expects($this->once()) - ->method('__invoke') - ->with($request) - ->willReturn(Attempt::result($identity = $this->createMock(Identity::class))); - $notCalled - ->expects($this->never()) - ->method('__invoke'); - - $this->assertSame($identity, $authenticate($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} From 03d6ceacba85bce0e8e3a23a69db74cfc02de076 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 24 Aug 2025 16:12:39 +0200 Subject: [PATCH 4/7] remove ValidateAuthrizationHeader --- CHANGELOG.md | 1 + src/ValidateAuthorizationHeader.php | 33 ------- tests/ValidateAuthorizationHeaderTest.php | 111 ---------------------- 3 files changed, 1 insertion(+), 144 deletions(-) delete mode 100644 src/ValidateAuthorizationHeader.php delete mode 100644 tests/ValidateAuthorizationHeaderTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 91c5cc7..f7449f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - All resolvers have been replaced by `callable`s - `Innmind\HttpAuthentication\ViaStorage` - `Innmind\HttpAuthentication\Any` +- `Innmind\HttpAuthentication\ValidateAuthorizationHeader` ## 4.0.0 - 2023-11-01 diff --git a/src/ValidateAuthorizationHeader.php b/src/ValidateAuthorizationHeader.php deleted file mode 100644 index ff85028..0000000 --- a/src/ValidateAuthorizationHeader.php +++ /dev/null @@ -1,33 +0,0 @@ -authenticate = $authenticate; - } - - public function __invoke(ServerRequest $request): Attempt - { - if (!$request->headers()->contains('Authorization')) { - return ($this->authenticate)($request); - } - - return $request - ->headers() - ->find(Authorization::class) - ->attempt(static fn() => new \RuntimeException('No Authorization header')) - ->flatMap(fn() => ($this->authenticate)($request)); - } -} diff --git a/tests/ValidateAuthorizationHeaderTest.php b/tests/ValidateAuthorizationHeaderTest.php deleted file mode 100644 index 7c2eff1..0000000 --- a/tests/ValidateAuthorizationHeaderTest.php +++ /dev/null @@ -1,111 +0,0 @@ -assertInstanceOf( - Authenticator::class, - new ValidateAuthorizationHeader( - $this->createMock(Authenticator::class), - ), - ); - } - - public function testForwardAuthenticationWhenNoHeader() - { - $validate = new ValidateAuthorizationHeader( - $authenticate = $this->createMock(Authenticator::class), - ); - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - ); - $authenticate - ->expects($this->once()) - ->method('__invoke') - ->with($request) - ->willReturn(Attempt::result($expected = $this->createMock(Identity::class))); - - $this->assertSame($expected, $validate($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } - - public function testReturnNothingWhenHeaderNotOfExpectedType() - { - $validate = new ValidateAuthorizationHeader( - $authenticate = $this->createMock(Authenticator::class), - ); - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - Headers::of( - new Header( - 'Authorization', - new Value('Bearer foo'), - ), - ), - ); - $authenticate - ->expects($this->never()) - ->method('__invoke'); - - $this->assertNull($validate($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } - - public function testForwardAuthenticationWhenValidHeader() - { - $validate = new ValidateAuthorizationHeader( - $authenticate = $this->createMock(Authenticator::class), - ); - $request = ServerRequest::of( - Url::of('/'), - Method::get, - ProtocolVersion::v11, - Headers::of( - new Authorization( - new AuthorizationValue('Bearer', 'foo'), - ), - ), - ); - $authenticate - ->expects($this->once()) - ->method('__invoke') - ->with($request) - ->willReturn(Attempt::result($expected = $this->createMock(Identity::class))); - - $this->assertSame($expected, $validate($request)->match( - static fn($identity) => $identity, - static fn() => null, - )); - } -} From f570888a364defbf876935ae53aac0f7075a4171 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 24 Aug 2025 16:15:25 +0200 Subject: [PATCH 5/7] remove Authenticator interface --- CHANGELOG.md | 3 ++- src/Authenticator.php | 15 --------------- src/ViaAuthorization.php | 5 ++++- src/ViaBasicAuthorization.php | 5 ++++- src/ViaForm.php | 5 ++++- src/ViaUrlAuthority.php | 5 ++++- tests/ViaAuthorizationTest.php | 9 --------- tests/ViaBasicAuthorizationTest.php | 9 --------- tests/ViaFormTest.php | 9 --------- tests/ViaUrlAuthorityTest.php | 9 --------- 10 files changed, 18 insertions(+), 56 deletions(-) delete mode 100644 src/Authenticator.php diff --git a/CHANGELOG.md b/CHANGELOG.md index f7449f6..8e4658e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Changed -- `Innmind\HttpAuthentication\Authenticator::__invoke()` now returns an `Innmind\Immutable\Attempt` +- All authenticators now return an `Innmind\Immutable\Attempt` ### Removed @@ -12,6 +12,7 @@ - `Innmind\HttpAuthentication\ViaStorage` - `Innmind\HttpAuthentication\Any` - `Innmind\HttpAuthentication\ValidateAuthorizationHeader` +- `Innmind\HttpAuthentication\Authenticator` ## 4.0.0 - 2023-11-01 diff --git a/src/Authenticator.php b/src/Authenticator.php deleted file mode 100644 index 9c5c5d9..0000000 --- a/src/Authenticator.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ - public function __invoke(ServerRequest $request): Attempt; -} diff --git a/src/ViaAuthorization.php b/src/ViaAuthorization.php index 8a2a484..be3c5e2 100644 --- a/src/ViaAuthorization.php +++ b/src/ViaAuthorization.php @@ -13,7 +13,7 @@ Predicate\Instance, }; -final class ViaAuthorization implements Authenticator +final class ViaAuthorization { /** @var callable(AuthorizationValue): Attempt */ private $resolve; @@ -26,6 +26,9 @@ public function __construct(callable $resolve) $this->resolve = $resolve; } + /** + * @return Attempt + */ public function __invoke(ServerRequest $request): Attempt { return $request diff --git a/src/ViaBasicAuthorization.php b/src/ViaBasicAuthorization.php index dbe305e..7742503 100644 --- a/src/ViaBasicAuthorization.php +++ b/src/ViaBasicAuthorization.php @@ -9,7 +9,7 @@ }; use Innmind\Immutable\Attempt; -final class ViaBasicAuthorization implements Authenticator +final class ViaBasicAuthorization { /** @var callable(string, string): Attempt */ private $resolve; @@ -22,6 +22,9 @@ public function __construct(callable $resolve) $this->resolve = $resolve; } + /** + * @return Attempt + */ public function __invoke(ServerRequest $request): Attempt { return $request diff --git a/src/ViaForm.php b/src/ViaForm.php index 9462654..e85c260 100644 --- a/src/ViaForm.php +++ b/src/ViaForm.php @@ -13,7 +13,7 @@ Attempt, }; -final class ViaForm implements Authenticator +final class ViaForm { /** @var callable(Form): Attempt */ private $resolve; @@ -26,6 +26,9 @@ public function __construct(callable $resolve) $this->resolve = $resolve; } + /** + * @return Attempt + */ public function __invoke(ServerRequest $request): Attempt { return Maybe::just($request) diff --git a/src/ViaUrlAuthority.php b/src/ViaUrlAuthority.php index 29962ae..52a1228 100644 --- a/src/ViaUrlAuthority.php +++ b/src/ViaUrlAuthority.php @@ -10,7 +10,7 @@ }; use Innmind\Immutable\Attempt; -final class ViaUrlAuthority implements Authenticator +final class ViaUrlAuthority { /** @var callable(User, Password): Attempt */ private $resolve; @@ -23,6 +23,9 @@ public function __construct(callable $resolve) $this->resolve = $resolve; } + /** + * @return Attempt + */ public function __invoke(ServerRequest $request): Attempt { $user = $request->url()->authority()->userInformation()->user(); diff --git a/tests/ViaAuthorizationTest.php b/tests/ViaAuthorizationTest.php index 245a6bb..942b2ea 100644 --- a/tests/ViaAuthorizationTest.php +++ b/tests/ViaAuthorizationTest.php @@ -5,7 +5,6 @@ use Innmind\HttpAuthentication\{ ViaAuthorization, - Authenticator, Identity, }; use Innmind\Http\{ @@ -24,14 +23,6 @@ class ViaAuthorizationTest extends TestCase { - public function testInterface() - { - $this->assertInstanceOf( - Authenticator::class, - new ViaAuthorization(static fn() => null), - ); - } - public function testReturnNothingWhenNoAuthorizationHeader() { $authenticate = new ViaAuthorization( diff --git a/tests/ViaBasicAuthorizationTest.php b/tests/ViaBasicAuthorizationTest.php index a5288d7..751527e 100644 --- a/tests/ViaBasicAuthorizationTest.php +++ b/tests/ViaBasicAuthorizationTest.php @@ -5,7 +5,6 @@ use Innmind\HttpAuthentication\{ ViaBasicAuthorization, - Authenticator, Identity, }; use Innmind\Http\{ @@ -23,14 +22,6 @@ class ViaBasicAuthorizationTest extends TestCase { - public function testInterface() - { - $this->assertInstanceOf( - Authenticator::class, - new ViaBasicAuthorization(static fn() => null), - ); - } - public function testReturnNothingWhenNoAuthorizationHeader() { $authenticate = new ViaBasicAuthorization( diff --git a/tests/ViaFormTest.php b/tests/ViaFormTest.php index 7f4e517..9a44cd7 100644 --- a/tests/ViaFormTest.php +++ b/tests/ViaFormTest.php @@ -5,7 +5,6 @@ use Innmind\HttpAuthentication\{ ViaForm, - Authenticator, Identity, }; use Innmind\Http\{ @@ -19,14 +18,6 @@ class ViaFormTest extends TestCase { - public function testInterface() - { - $this->assertInstanceOf( - Authenticator::class, - new ViaForm(static fn() => null), - ); - } - public function testReturnNothingWhenNotPostRequest() { $authenticate = new ViaForm( diff --git a/tests/ViaUrlAuthorityTest.php b/tests/ViaUrlAuthorityTest.php index 3322eeb..54e6cd7 100644 --- a/tests/ViaUrlAuthorityTest.php +++ b/tests/ViaUrlAuthorityTest.php @@ -5,7 +5,6 @@ use Innmind\HttpAuthentication\{ ViaUrlAuthority, - Authenticator, Identity, }; use Innmind\Url\Url; @@ -19,14 +18,6 @@ class ViaUrlAuthorityTest extends TestCase { - public function testInterface() - { - $this->assertInstanceOf( - Authenticator::class, - new ViaUrlAuthority(static fn() => null), - ); - } - public function testReturnNothingWhenNoUserProvidedInTheUrl() { $authenticate = new ViaUrlAuthority( From bcace9c1c263e282296bf2f0ac4f146f9ea671f2 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 24 Aug 2025 16:22:39 +0200 Subject: [PATCH 6/7] allow to return any type --- CHANGELOG.md | 1 + src/ViaAuthorization.php | 9 ++++++--- src/ViaBasicAuthorization.php | 9 ++++++--- src/ViaForm.php | 9 ++++++--- src/ViaUrlAuthority.php | 11 +++++++---- tests/ViaAuthorizationTest.php | 10 +++------- tests/ViaBasicAuthorizationTest.php | 10 +++------- tests/ViaFormTest.php | 10 +++------- tests/ViaUrlAuthorityTest.php | 10 +++------- 9 files changed, 38 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e4658e..ed274b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changed - All authenticators now return an `Innmind\Immutable\Attempt` +- All authenticators can return any type inside the `Attempt` ### Removed diff --git a/src/ViaAuthorization.php b/src/ViaAuthorization.php index be3c5e2..4374121 100644 --- a/src/ViaAuthorization.php +++ b/src/ViaAuthorization.php @@ -13,13 +13,16 @@ Predicate\Instance, }; +/** + * @template T + */ final class ViaAuthorization { - /** @var callable(AuthorizationValue): Attempt */ + /** @var callable(AuthorizationValue): Attempt */ private $resolve; /** - * @param callable(AuthorizationValue): Attempt $resolve + * @param callable(AuthorizationValue): Attempt $resolve */ public function __construct(callable $resolve) { @@ -27,7 +30,7 @@ public function __construct(callable $resolve) } /** - * @return Attempt + * @return Attempt */ public function __invoke(ServerRequest $request): Attempt { diff --git a/src/ViaBasicAuthorization.php b/src/ViaBasicAuthorization.php index 7742503..7caa170 100644 --- a/src/ViaBasicAuthorization.php +++ b/src/ViaBasicAuthorization.php @@ -9,13 +9,16 @@ }; use Innmind\Immutable\Attempt; +/** + * @template T + */ final class ViaBasicAuthorization { - /** @var callable(string, string): Attempt */ + /** @var callable(string, string): Attempt */ private $resolve; /** - * @param callable(string, string): Attempt $resolve + * @param callable(string, string): Attempt $resolve */ public function __construct(callable $resolve) { @@ -23,7 +26,7 @@ public function __construct(callable $resolve) } /** - * @return Attempt + * @return Attempt */ public function __invoke(ServerRequest $request): Attempt { diff --git a/src/ViaForm.php b/src/ViaForm.php index e85c260..002b4ee 100644 --- a/src/ViaForm.php +++ b/src/ViaForm.php @@ -13,13 +13,16 @@ Attempt, }; +/** + * @template T + */ final class ViaForm { - /** @var callable(Form): Attempt */ + /** @var callable(Form): Attempt */ private $resolve; /** - * @param callable(Form): Attempt $resolve + * @param callable(Form): Attempt $resolve */ public function __construct(callable $resolve) { @@ -27,7 +30,7 @@ public function __construct(callable $resolve) } /** - * @return Attempt + * @return Attempt */ public function __invoke(ServerRequest $request): Attempt { diff --git a/src/ViaUrlAuthority.php b/src/ViaUrlAuthority.php index 52a1228..aecb7b4 100644 --- a/src/ViaUrlAuthority.php +++ b/src/ViaUrlAuthority.php @@ -10,13 +10,16 @@ }; use Innmind\Immutable\Attempt; +/** + * @template T + */ final class ViaUrlAuthority { - /** @var callable(User, Password): Attempt */ + /** @var callable(User, Password): Attempt */ private $resolve; /** - * @param callable(User, Password): Attempt $resolve + * @param callable(User, Password): Attempt $resolve */ public function __construct(callable $resolve) { @@ -24,7 +27,7 @@ public function __construct(callable $resolve) } /** - * @return Attempt + * @return Attempt */ public function __invoke(ServerRequest $request): Attempt { @@ -32,7 +35,7 @@ public function __invoke(ServerRequest $request): Attempt $password = $request->url()->authority()->userInformation()->password(); if ($user->equals(User::none()) && $password->equals(Password::none())) { - /** @var Attempt */ + /** @var Attempt */ return Attempt::error(new \RuntimeException('No authentication provided')); } diff --git a/tests/ViaAuthorizationTest.php b/tests/ViaAuthorizationTest.php index 942b2ea..90ba5cf 100644 --- a/tests/ViaAuthorizationTest.php +++ b/tests/ViaAuthorizationTest.php @@ -3,10 +3,7 @@ namespace Tests\Innmind\HttpAuthentication; -use Innmind\HttpAuthentication\{ - ViaAuthorization, - Identity, -}; +use Innmind\HttpAuthentication\ViaAuthorization; use Innmind\Http\{ ServerRequest, Method, @@ -62,9 +59,8 @@ public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly() public function testInvokation() { - $identity = $this->createMock(Identity::class); $authenticate = new ViaAuthorization( - static fn() => Attempt::result($identity), + static fn($value) => Attempt::result($value), ); $expected = new AuthorizationValue('Bearer', 'foo'); $request = ServerRequest::of( @@ -76,7 +72,7 @@ public function testInvokation() ), ); - $this->assertSame($identity, $authenticate($request)->match( + $this->assertSame($expected, $authenticate($request)->match( static fn($identity) => $identity, static fn() => null, )); diff --git a/tests/ViaBasicAuthorizationTest.php b/tests/ViaBasicAuthorizationTest.php index 751527e..e12ebdf 100644 --- a/tests/ViaBasicAuthorizationTest.php +++ b/tests/ViaBasicAuthorizationTest.php @@ -3,10 +3,7 @@ namespace Tests\Innmind\HttpAuthentication; -use Innmind\HttpAuthentication\{ - ViaBasicAuthorization, - Identity, -}; +use Innmind\HttpAuthentication\ViaBasicAuthorization; use Innmind\Http\{ ServerRequest, Method, @@ -81,9 +78,8 @@ public function testReturnNothingWhenNotBasicAuthorization() public function testInvokation() { - $identity = $this->createMock(Identity::class); $authenticate = new ViaBasicAuthorization( - static fn() => Attempt::result($identity), + static fn($user, $password) => Attempt::result([$user, $password]), ); $request = ServerRequest::of( Url::of('/'), @@ -94,7 +90,7 @@ public function testInvokation() ), ); - $this->assertSame($identity, $authenticate($request)->match( + $this->assertSame(['foo', 'bar'], $authenticate($request)->match( static fn($identity) => $identity, static fn() => null, )); diff --git a/tests/ViaFormTest.php b/tests/ViaFormTest.php index 9a44cd7..a8f2a50 100644 --- a/tests/ViaFormTest.php +++ b/tests/ViaFormTest.php @@ -3,10 +3,7 @@ namespace Tests\Innmind\HttpAuthentication; -use Innmind\HttpAuthentication\{ - ViaForm, - Identity, -}; +use Innmind\HttpAuthentication\ViaForm; use Innmind\Http\{ ServerRequest, Method, @@ -37,9 +34,8 @@ public function testReturnNothingWhenNotPostRequest() public function testInvokation() { - $identity = $this->createMock(Identity::class); $authenticate = new ViaForm( - static fn() => Attempt::result($identity), + static fn($value) => Attempt::result($value), ); $request = ServerRequest::of( Url::of('/'), @@ -47,7 +43,7 @@ public function testInvokation() ProtocolVersion::v11, ); - $this->assertSame($identity, $authenticate($request)->match( + $this->assertSame($request->form(), $authenticate($request)->match( static fn($identity) => $identity, static fn() => null, )); diff --git a/tests/ViaUrlAuthorityTest.php b/tests/ViaUrlAuthorityTest.php index 54e6cd7..8048219 100644 --- a/tests/ViaUrlAuthorityTest.php +++ b/tests/ViaUrlAuthorityTest.php @@ -3,10 +3,7 @@ namespace Tests\Innmind\HttpAuthentication; -use Innmind\HttpAuthentication\{ - ViaUrlAuthority, - Identity, -}; +use Innmind\HttpAuthentication\ViaUrlAuthority; use Innmind\Url\Url; use Innmind\Http\{ ServerRequest, @@ -38,9 +35,8 @@ public function testReturnNothingWhenNoUserProvidedInTheUrl() public function testInvokation() { - $identity = $this->createMock(Identity::class); $authenticate = new ViaUrlAuthority( - static fn() => Attempt::result($identity), + static fn($user, $password) => Attempt::result([$user, $password]), ); $url = Url::of('https://user:password@localhost/'); $user = $url->authority()->userInformation()->user(); @@ -51,7 +47,7 @@ public function testInvokation() ProtocolVersion::v11, ); - $this->assertSame($identity, $authenticate($request)->match( + $this->assertSame([$user, $password], $authenticate($request)->match( static fn($identity) => $identity, static fn() => null, )); From 9c388901a52c1612166c0394437aa4f252e95073 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 24 Aug 2025 16:23:30 +0200 Subject: [PATCH 7/7] remove Identity --- CHANGELOG.md | 1 + src/Identity.php | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 src/Identity.php diff --git a/CHANGELOG.md b/CHANGELOG.md index ed274b4..95868c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - `Innmind\HttpAuthentication\Any` - `Innmind\HttpAuthentication\ValidateAuthorizationHeader` - `Innmind\HttpAuthentication\Authenticator` +- `Innmind\HttpAuthentication\Identity` ## 4.0.0 - 2023-11-01 diff --git a/src/Identity.php b/src/Identity.php deleted file mode 100644 index 1557d35..0000000 --- a/src/Identity.php +++ /dev/null @@ -1,9 +0,0 @@ -