Skip to content

Commit f7b477a

Browse files
[HttpFoundation] Add PRIVATE_SUBNETS as a shortcut for private IP address ranges to Request::setTrustedProxies()
1 parent e3c09d4 commit f7b477a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ public function getConfigTreeBuilder(): TreeBuilder
111111
->beforeNormalization()->ifString()->then(fn ($v) => [$v])->end()
112112
->prototype('scalar')->end()
113113
->end()
114-
->scalarNode('trusted_proxies')
114+
->variableNode('trusted_proxies')
115115
->beforeNormalization()
116-
->ifTrue(fn ($v) => 'private_ranges' === $v)
117-
->then(fn ($v) => implode(',', IpUtils::PRIVATE_SUBNETS))
116+
->ifTrue(fn ($v) => 'private_ranges' === $v || 'PRIVATE_SUBNETS' === $v)
117+
->then(fn () => IpUtils::PRIVATE_SUBNETS)
118118
->end()
119119
->end()
120120
->arrayNode('trusted_headers')

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2354,7 +2354,7 @@ public function testTrustedProxiesWithPrivateRanges()
23542354
{
23552355
$container = $this->createContainerFromFile('trusted_proxies_private_ranges');
23562356

2357-
$this->assertSame(IpUtils::PRIVATE_SUBNETS, array_map('trim', explode(',', $container->getParameter('kernel.trusted_proxies'))));
2357+
$this->assertSame(IpUtils::PRIVATE_SUBNETS, $container->getParameter('kernel.trusted_proxies'));
23582358
}
23592359

23602360
public function testWebhook()

0 commit comments

Comments
 (0)