Skip to content

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Oct 6, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

This feature addresses https://github.com/symfony/symfony/pull/61949/files#r2402280654 and hardens HttpFoundation by giving control over which HTTP methods can be overridden:

Request::setAllowedHttpMethodOverride(['PUT', 'PATCH', 'DELETE']);

Providing no method disables verb tunneling altogether:

Request::setAllowedHttpMethodOverride([]);

This setting can be set using standard Symfony configuration:

framework:
    allowed_http_method_override: ['PUT', 'DELETE', 'PATCH']

2 implementations note:

  • This doesn't update the XSD file on purpose: that format is deprecated and handling it would mean adding more complexity that nobody will benefit from in practice.
  • This isn't compatible with defining the list of allowed methods using env vars. This could be added later if one has a use case for that. Until it happens, I prefer keeping the code simpler.

@nicolas-grekas nicolas-grekas force-pushed the hf-list-verbs-override branch 3 times, most recently from 93d5adf to ff33c15 Compare October 8, 2025 10:10
@nicolas-grekas nicolas-grekas changed the title [HttpFoundation] Add Request::$allowedHttpMethodOverride to list which HTTP methods can be overridden [HttpFoundation] Add Request::set/getAllowedHttpMethodOverride() to list which HTTP methods can be overridden Oct 8, 2025
@nicolas-grekas nicolas-grekas force-pushed the hf-list-verbs-override branch from ff33c15 to 4704a8e Compare October 8, 2025 10:20
@nicolas-grekas nicolas-grekas force-pushed the hf-list-verbs-override branch 3 times, most recently from a7f5d06 to eac4c7c Compare October 8, 2025 22:02
@nicolas-grekas nicolas-grekas force-pushed the hf-list-verbs-override branch from eac4c7c to a4f51c9 Compare October 8, 2025 22:20
}
$container->parameterCannotBeEmpty('kernel.secret', 'A non-empty value for the parameter "kernel.secret" is required. Did you forget to configure the '.$emptySecretHint.'?');

$container->setParameter('kernel.http_method_override', $config['http_method_override']);
Copy link
Member Author

@nicolas-grekas nicolas-grekas Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that this naming is quite unfortunate as it's confusing: the setting is only about allowing the use of the _method parameter. Overriding using the header is always available.
A better name would have been enable_http_method_override_parameter, like the name of the corresponding static method. In case anyone wants to follow up in another PR (deprecating the option, the parameter, BC/FC layer, etc.).

@fabpot
Copy link
Member

fabpot commented Oct 10, 2025

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 1a5b5e5 into symfony:7.4 Oct 10, 2025
11 of 12 checks passed
}

if (null !== $allowedHttpMethodOverride) {
$container->getDefinition('http_cache')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git blame tells me its for configuring this before httpcache is created, which can happen super early before bundles are initialized

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed, this is needed for the wrong behaviour reported in #40618 (fixed in #40619).

@nicolas-grekas nicolas-grekas deleted the hf-list-verbs-override branch October 11, 2025 10:43
This was referenced Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants