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()
89
89
90
90
// PHP_AUTH_USER/PHP_AUTH_PW
91
91
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 ' ] ?? '' ) );
93
93
} elseif (isset ($ headers ['PHP_AUTH_DIGEST ' ])) {
94
94
$ headers ['AUTHORIZATION ' ] = $ headers ['PHP_AUTH_DIGEST ' ];
95
95
}
Original file line number Diff line number Diff line change @@ -57,6 +57,16 @@ public function testHttpPasswordIsOptional()
57
57
], $ bag ->getHeaders ());
58
58
}
59
59
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
+
60
70
public function testHttpBasicAuthWithPhpCgi ()
61
71
{
62
72
$ bag = new ServerBag (['HTTP_AUTHORIZATION ' => 'Basic ' .base64_encode ('foo:bar ' )]);
You can’t perform that action at this time.
0 commit comments