File tree 3 files changed +29
-2
lines changed
src/Symfony/Component/Security/Http
3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1
1
| Q | A
2
2
| ------------- | ---
3
- | Branch? | 5.4 for features / 4.4, 5.2 or 5.3 for bug fixes <!-- see below -->
3
+ | Branch? | 5.4 for features / 4.4 or 5.3 for bug fixes <!-- see below -->
4
4
| Bug fix? | yes/no
5
5
| New feature? | yes/no <!-- please update src/**/CHANGELOG.md files -->
6
6
| Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public function supports(Request $request): ?bool
49
49
if (null !== $ this ->logger ) {
50
50
if ('https ' === $ request ->headers ->get ('X-Forwarded-Proto ' )) {
51
51
$ this ->logger ->info ('Redirecting to HTTPS. ("X-Forwarded-Proto" header is set to "https" - did you set "trusted_proxies" correctly?) ' );
52
- } elseif (str_contains ($ request ->headers ->get ('Forwarded ' ), 'proto=https ' )) {
52
+ } elseif (str_contains ($ request ->headers ->get ('Forwarded ' , '' ), 'proto=https ' )) {
53
53
$ this ->logger ->info ('Redirecting to HTTPS. ("Forwarded" header is set to "proto=https" - did you set "trusted_proxies" correctly?) ' );
54
54
} else {
55
55
$ this ->logger ->info ('Redirecting to HTTPS. ' );
Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \Security \Http \Tests \Firewall ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Psr \Log \NullLogger ;
16
+ use Symfony \Component \HttpFoundation \HeaderBag ;
15
17
use Symfony \Component \HttpFoundation \Request ;
16
18
use Symfony \Component \HttpFoundation \Response ;
17
19
use Symfony \Component \HttpKernel \Event \RequestEvent ;
@@ -153,4 +155,29 @@ public function testHandleWithSecuredRequestAndHttpChannel()
153
155
154
156
$ this ->assertSame ($ response , $ event ->getResponse ());
155
157
}
158
+
159
+ public function testSupportsWithoutHeaders ()
160
+ {
161
+ $ request = $ this ->createMock (Request::class);
162
+ $ request
163
+ ->expects ($ this ->any ())
164
+ ->method ('isSecure ' )
165
+ ->willReturn (false )
166
+ ;
167
+ $ request ->headers = new HeaderBag ();
168
+
169
+ $ accessMap = $ this ->createMock (AccessMapInterface::class);
170
+ $ accessMap
171
+ ->expects ($ this ->any ())
172
+ ->method ('getPatterns ' )
173
+ ->with ($ this ->equalTo ($ request ))
174
+ ->willReturn ([[], 'https ' ])
175
+ ;
176
+
177
+ $ entryPoint = $ this ->createMock (AuthenticationEntryPointInterface::class);
178
+
179
+ $ listener = new ChannelListener ($ accessMap , $ entryPoint , new NullLogger ());
180
+
181
+ $ this ->assertTrue ($ listener ->supports ($ request ));
182
+ }
156
183
}
You can’t perform that action at this time.
0 commit comments