Skip to content

[SecurityBundle] Merging configuration requires access_decision_manager to be in every configuration #25609

Closed
@biozshock

Description

@biozshock
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.2

In an application i need to change access_decision_manager.strategy to "unanimous".

After the change symfony/security-bundle@06393da#diff-5382c0b1af9e9c09693d49cd3b00aac9R62 i can not have a configuration in config_test.yml that just adds another firewall:

security:
    firewalls:
        default:
            http_basic: ~

Because here https://github.com/symfony/symfony/blob/v3.4.2/src/Symfony/Component/Config/Definition/BaseNode.php#L269 config variable $rightSide for the second file will contain [access_decision_manager][strategy] = 'affirmative' and after the merge it will overwrite any value in security.yml for access_decision_manager.strategy path.

Test case:

namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\DependencyInjection\MainConfiguration;
use Symfony\Component\Config\Definition\Processor;

class IssueTest extends TestCase
{
    /**
     * The minimal, required config needed to not have any required validation
     * issues.
     */
    protected static $minimalConfig = array(
        'providers' => array(
            'stub' => array(
                'id' => 'foo',
            ),
        ),
        'firewalls' => array(
            'stub' => array(),
            'logout_on_user_change' => true,
        ),
    );

    public function testConfigMergeWithAccessDecisionManager()
    {
        $config = array(
            'access_decision_manager' => array(
                'strategy' => 'unanimous',
            ),
        );
        $config = array_merge(static::$minimalConfig, $config);

        $config2 = array();

        $processor = new Processor();
        $configuration = new MainConfiguration(array(), array());
        $processedConfig = $processor->processConfiguration($configuration, array($config, $config2));

        $this->assertEquals('unanimous', $processedConfig['access_decision_manager']['strategy']);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions