Skip to content

Commit

Permalink
merged branch denderello/strategy-validation (PR #8710)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

[Security] Added a check for strategies in AccessDecisionManager

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8646
| License       | MIT

Commits
-------

ee36380 [Security] Added a check for strategies in AccessDecisionManager
  • Loading branch information
fabpot committed Aug 13, 2013
2 parents cb7aebe + ee36380 commit a0a1c31
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -43,8 +43,13 @@ public function __construct(array $voters, $strategy = 'affirmative', $allowIfAl
throw new \InvalidArgumentException('You must at least add one voter.');
}

$strategyMethod = 'decide'.ucfirst($strategy);
if (!is_callable(array($this, $strategyMethod))) {
throw new \InvalidArgumentException(sprintf('The strategy "%s" is not supported.', $strategy));
}

$this->voters = $voters;
$this->strategy = 'decide'.ucfirst($strategy);
$this->strategy = $strategyMethod;
$this->allowIfAllAbstainDecisions = (Boolean) $allowIfAllAbstainDecisions;
$this->allowIfEqualGrantedDeniedDecisions = (Boolean) $allowIfEqualGrantedDeniedDecisions;
}
Expand Down
Expand Up @@ -54,6 +54,14 @@ public function testSetVotersEmpty()
$manager = new AccessDecisionManager(array());
}

/**
* @expectedException \InvalidArgumentException
*/
public function testSetUnsupportedStrategy()
{
new AccessDecisionManager(array($this->getVoter(VoterInterface::ACCESS_GRANTED)), 'fooBar');
}

/**
* @dataProvider getStrategyTests
*/
Expand Down

0 comments on commit a0a1c31

Please sign in to comment.