8000 [SecurityBundle] do not override custom access decision configs by xabbuh · Pull Request #28793 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[SecurityBundle] do not override custom access decision configs #28793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations 8000
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public function getConfigTreeBuilder()
return false;
})
->then(function ($v) {
$v['access_decision_manager'] = array(
'strategy' => AccessDecisionManager::STRATEGY_AFFIRMATIVE,
);
$v['access_decision_manager']['strategy'] = AccessDecisionManager::STRATEGY_AFFIRMATIVE;

return $v;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,22 @@ public function testCustomAccessDecisionManagerService()

/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage "strategy" and "service" cannot be used together.
* @expectedExceptionMessage Invalid configuration for path "security.access_decision_manager": "strategy" and "service" cannot be used together.
*/
public function testAccessDecisionManagerServiceAndStrategyCannotBeUsedAtTheSameTime()
{
$container = $this->getContainer('access_decision_manager_service_and_strategy');
$this->getContainer('access_decision_manager_service_and_strategy');
}

public function testAccessDecisionManagerOptionsAreNotOverriddenByImplicitStrategy()
{
$container = $this->getContainer('access_decision_manager_customized_config');

$accessDecisionManagerDefinition = $container->getDefinition('security.access.decision_manager');

$this->assertSame(AccessDecisionManager::STRATEGY_AFFIRMATIVE, $accessDecisionManagerDefinition->getArgument(1));
$this->assertTrue($accessDecisionManagerDefinition->getArgument(2));
$this->assertFalse($accessDecisionManagerDefinition->getArgument(3));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

$container->loadFromExtension('security', array(
'access_decision_manager' => array(
'allow_if_all_abstain' => true,
'allow_if_equal_granted_denied' => false,
),
'providers' => array(
'default' => array(
'memory' => array(
'users' => array(
'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'),
),
),
),
),
'firewalls' => array(
'simple' => array('pattern' => '/login', 'security' => false),
),
));
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<srv:container xmlns="http://symfony.com/schema/dic/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<config>
<access-decision-manager allow-if-all-abstain="true" allow-if-equal-granted-denied="false" />

<provider name="default">
<memory>
<user name="foo" password="foo" roles="ROLE_USER" />
</memory>
</provider>

<firewall name="simple" pattern="/login" security="false" />
</config>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
security:
access_decision_manager:
allow_if_all_abstain: true
allow_if_equal_granted_denied: false
providers:
default:
memory:
users:
foo: { password: foo, roles: ROLE_USER }
firewalls:
simple: { pattern: /login, security: false }
0