38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
![]() |
=== How to fix it in Symfony
|
||
|
|
||
|
=== Code examples
|
||
|
|
||
|
In a Symfony Security's context, session fixation protection can be disabled with the value ``++none++`` for the ``++session_fixation_strategy++`` attribute.
|
||
|
|
||
|
Session fixation protection is enabled by default in Symfony. It can be explicitly enabled with the values ``++migrate++`` and ``++invalidate++`` for the ``++session_fixation_strategy++`` attribute.
|
||
|
|
||
|
==== Noncompliant code example
|
||
|
|
||
|
[source,php,diff-id=1,diff-type=noncompliant]
|
||
|
----
|
||
|
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||
|
|
||
|
return static function (ContainerConfigurator $container) {
|
||
|
$container->extension('security', [
|
||
|
'session_fixation_strategy' => 'none', // Noncompliant
|
||
|
]);
|
||
|
};
|
||
|
----
|
||
|
|
||
|
==== Compliant solution
|
||
|
|
||
|
[source,php,diff-id=1,diff-type=compliant]
|
||
|
----
|
||
|
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||
|
|
||
|
return static function (ContainerConfigurator $container) {
|
||
|
$container->extension('security', [
|
||
|
'session_fixation_strategy' => 'migrate',
|
||
|
]);
|
||
|
};
|
||
|
----
|
||
|
|
||
|
=== How does this work?
|
||
|
|
||
|
include::../../common/fix/new-session.adoc[]
|