File tree Expand file tree Collapse file tree 5 files changed +13
-20
lines changed
Expand file tree Collapse file tree 5 files changed +13
-20
lines changed Original file line number Diff line number Diff line change 66
77- All authenticators now return an ` Innmind\Immutable\Attempt `
88- All authenticators can return any type inside the ` Attempt `
9+ - Requires ` innmind/foundation:~1.9 `
910
1011### Removed
1112
Original file line number Diff line number Diff line change 1616 },
1717 "require" : {
1818 "php" : " ~8.2" ,
19- "innmind/immutable" : " ~5.18" ,
20- "innmind/http" : " ~7.0"
19+ "innmind/foundation" : " ~1.9"
2120 },
2221 "autoload" : {
2322 "psr-4" : {
Original file line number Diff line number Diff line change 66use Innmind \Http \{
77 ServerRequest ,
88 Header \Authorization ,
9- Header \AuthorizationValue ,
10- };
11- use Innmind \Immutable \{
12- Attempt ,
13- Predicate \Instance ,
149};
10+ use Innmind \Immutable \Attempt ;
1511
1612/**
1713 * @template T
1814 */
1915final class ViaAuthorization
2016{
21- /** @var callable(AuthorizationValue ): Attempt<T> */
17+ /** @var callable(Authorization ): Attempt<T> */
2218 private $ resolve ;
2319
2420 /**
25- * @param callable(AuthorizationValue ): Attempt<T> $resolve
21+ * @param callable(Authorization ): Attempt<T> $resolve
2622 */
2723 public function __construct (callable $ resolve )
2824 {
@@ -37,8 +33,6 @@ public function __invoke(ServerRequest $request): Attempt
3733 return $ request
3834 ->headers ()
3935 ->find (Authorization::class)
40- ->flatMap (static fn ($ header ) => $ header ->values ()->find (static fn () => true ))
41- ->keep (Instance::of (AuthorizationValue::class))
4236 ->attempt (static fn () => new \RuntimeException ('Failed to resolve identity ' ))
4337 ->flatMap (fn ($ value ) => ($ this ->resolve )($ value ));
4438 }
Original file line number Diff line number Diff line change 99 Method ,
1010 ProtocolVersion ,
1111 Headers ,
12- Header \ Header ,
13- Header \Value \ Value ,
12+ Header ,
13+ Header \Value ,
1414 Header \Authorization ,
15- Header \AuthorizationValue ,
1615};
1716use Innmind \Url \Url ;
1817use Innmind \Immutable \Attempt ;
@@ -47,7 +46,7 @@ public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly()
4746 Method::get,
4847 ProtocolVersion::v11,
4948 Headers::of (
50- new Header ('Authorization ' , new Value ('Basic foo ' )),
49+ Header:: of ('Authorization ' , Value:: of ('Basic foo ' )),
5150 ),
5251 );
5352
@@ -62,13 +61,13 @@ public function testInvokation()
6261 $ authenticate = new ViaAuthorization (
6362 static fn ($ value ) => Attempt::result ($ value ),
6463 );
65- $ expected = new AuthorizationValue ('Bearer ' , 'foo ' );
64+ $ expected = Authorization:: of ('Bearer ' , 'foo ' );
6665 $ request = ServerRequest::of (
6766 Url::of ('/ ' ),
6867 Method::get,
6968 ProtocolVersion::v11,
7069 Headers::of (
71- new Authorization ( $ expected) ,
70+ $ expected ,
7271 ),
7372 );
7473
Original file line number Diff line number Diff line change 99 Method ,
1010 ProtocolVersion ,
1111 Headers ,
12- Header \ Header ,
13- Header \Value \ Value ,
12+ Header ,
13+ Header \Value ,
1414 Header \Authorization ,
1515};
1616use Innmind \Url \Url ;
@@ -46,7 +46,7 @@ public function testReturnNothingWhenAuthorizationHeaderNotParsedCorrectly()
4646 Method::get,
4747 ProtocolVersion::v11,
4848 Headers::of (
49- new Header ('Authorization ' , new Value ('Basic foo ' )),
49+ Header:: of ('Authorization ' , Value:: of ('Basic foo ' )),
5050 ),
5151 );
5252
You can’t perform that action at this time.
0 commit comments