File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public function getHeaders()
8989
9090 // PHP_AUTH_USER/PHP_AUTH_PW
9191 if (isset ($ headers ['PHP_AUTH_USER ' ])) {
92- $ headers ['AUTHORIZATION ' ] = 'Basic ' .base64_encode ($ headers ['PHP_AUTH_USER ' ].': ' .$ headers ['PHP_AUTH_PW ' ]);
92+ $ headers ['AUTHORIZATION ' ] = 'Basic ' .base64_encode ($ headers ['PHP_AUTH_USER ' ].': ' .( $ headers ['PHP_AUTH_PW ' ] ?? '' ) );
9393 } elseif (isset ($ headers ['PHP_AUTH_DIGEST ' ])) {
9494 $ headers ['AUTHORIZATION ' ] = $ headers ['PHP_AUTH_DIGEST ' ];
9595 }
Original file line number Diff line number Diff line change @@ -57,6 +57,16 @@ public function testHttpPasswordIsOptional()
5757 ], $ bag ->getHeaders ());
5858 }
5959
60+ public function testHttpPasswordIsOptionalWhenPassedWithHttpPrefix ()
61+ {
62+ $ bag = new ServerBag (['HTTP_PHP_AUTH_USER ' => 'foo ' ]);
63+
64+ $ this ->assertEquals ([
65+ 'AUTHORIZATION ' => 'Basic ' .base64_encode ('foo: ' ),
66+ 'PHP_AUTH_USER ' => 'foo ' ,
67+ ], $ bag ->getHeaders ());
68+ }
69+
6070 public function testHttpBasicAuthWithPhpCgi ()
6171 {
6272 $ bag = new ServerBag (['HTTP_AUTHORIZATION ' => 'Basic ' .base64_encode ('foo:bar ' )]);
You can’t perform that action at this time.
0 commit comments