Skip to content

[Security] Make it possible to give voters a weight in consensus decisions #16828

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

Closed
wants to merge 1 commit into from

Conversation

tPl0ch
Copy link

@tPl0ch tPl0ch commented Dec 3, 2015

After watching the "Dig in Security with Symfony" talk at SymfonyCon today, I
realized that there was no weighting mechanism in the current implementation.

It is not always true that each voter has the equal weight within a majority
vote. This feature PR accounts for that in a BC way.

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets None
License MIT
Doc PR None

Commit recap from rebase:

  • Introduced the WeightedVoterInterface that extends the VoterInterface
  • Added the abstract WeightedVoter as an easily usable base class
  • Added the Weight decorator to extend existing Voters with weighting
  • Refactored test structures for Voter
  • Added missing methods in Weight decorator required by VoterInterface
  • Added test case for Weight decorator
  • Added test case for abstract WeightedVoter
  • Added feature tests to AccessDecisionManagerTest
  • Implemented feature in AccessDecisionManager

@tPl0ch tPl0ch force-pushed the feature-weighted-voters branch 3 times, most recently from 5589e87 to cb4a18e Compare December 3, 2015 23:45
}

if ($weight < 1) {
throw new RuntimeException(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please put this in one single line.

@dosten
Copy link
Contributor

dosten commented Dec 4, 2015

👍 but this PR should be merged to master, as of 2.8 is already released.

@tPl0ch
Copy link
Author

tPl0ch commented Dec 4, 2015

@dosten If I read http://symfony.com/doc/master/contributing/code/patches.html#choose-the-right-branch correctly, a BC compatible feature should be compared against the 2.8 branch.

@tPl0ch tPl0ch force-pushed the feature-weighted-voters branch 2 times, most recently from deccf70 to 17da1f4 Compare December 4, 2015 20:19
@dosten
Copy link
Contributor

dosten commented Dec 4, 2015

@tPl0ch 2.8 is already released, so no new features are accepted, only bug fixes, same for 3.0. This new feature must be merged in master to be included in the 3.1 release.

final class Weight implements WeightedVoterInterface
{
private $voter;

Copy link
Contributor

Choose a reason for hiding this comment

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

We do not keep spaces between variables.

…sions

After watching the "Dig in Security with Symfony" talk at SymfonyCon today, I
 realized that there was no weighting mechanism in the current implementation.

It is not always true that each voter has the equal weight within a majority
 vote. This feature PR accounts for that in a BC way.

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

Commit recap from rebase:

- Introduced the `WeightedVoterInterface` that extends the `VoterInterface`
- Added the abstract `WeightedVoter` as an easily usable base class
- Added the `Weight` decorator to extend existing Voters with weighting
- Refactored test structures for `Voter`
- Added missing methods in `Weight` decorator required by `VoterInterface`
- Added test case for `Weight` decorator
- Added test case for abstract `WeightedVoter`
- Added feature tests to `AccessDecisionManagerTest`
- Implemented feature in `AccessDecisionManager`
- Fixed CodingStandards
@tPl0ch tPl0ch force-pushed the feature-weighted-voters branch from 17da1f4 to 8160138 Compare December 5, 2015 07:22
@tPl0ch
Copy link
Author

tPl0ch commented Dec 5, 2015

@dosten So closing this in favour of a PR against master.

@tPl0ch
Copy link
Author

tPl0ch commented Dec 5, 2015

@dosten See #16843

nicolas-grekas added a commit that referenced this pull request Jul 12, 2017
…ss decision manager service (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[Security] make it possible to configure a custom access decision manager service

| Q | A |
| --- | --- |
| Branch? | 3.4 |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #942, #14049, #15295, #16828, #16843, |
| License | MIT |
| Doc PR | TODO |

These changes will make it possible to let users define their own voting strategies without the need for custom compiler passes that replace the built-in `AccessDecisionManager` (see linked issues in the PR table for some use cases).

Commits
-------

e0913a2 add option to define the access decision manager
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.

3 participants