Merge lp:~adeuring/launchpad/milestone-sec-adapter into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Abel Deuring on 2012-10-17 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 16158 |
| Proposed branch: | lp:~adeuring/launchpad/milestone-sec-adapter |
| Merge into: | lp:launchpad |
| Diff against target: |
601 lines (+356/-77) 9 files modified
lib/lp/blueprints/tests/test_specification.py (+2/-22) lib/lp/registry/configure.zcml (+28/-21) lib/lp/registry/interfaces/milestone.py (+3/-0) lib/lp/registry/model/milestone.py (+11/-0) lib/lp/registry/tests/test_milestone.py (+247/-0) lib/lp/registry/tests/test_person.py (+13/-9) lib/lp/registry/tests/test_product.py (+2/-24) lib/lp/security.py (+20/-1) lib/lp/testing/__init__.py (+30/-0) |
| To merge this branch: | bzr merge lp:~adeuring/launchpad/milestone-sec-adapter |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Richard Harding (community) | 2012-10-16 | Approve on 2012-10-16 | |
|
Review via email:
|
|||
Commit Message
require policy grants for access to milestone related to non-public prudcts.
Description of the Change
This branch adds a "sharing wawre" security adapter for IMilestone.
Milestones related to private products are now only shown to persons
with policy grants for the product; the only exception are some
attributes that leak no information: the database ID, and the methods
userCanView(), checkAuthentica
The two latter methods should not appear at all -- we use adapters
for the security checks, so there is no need to define them in the
main class. And in fact they are not implemented at all.
Similary, IMilestone and some other interface classes included in
IMilestone define a few attributes that not implemented by class
Milestone.
We do not have very much time to finish the "Private products" story,
so I simply tried to ignore these inconsistencies.
Details of the change:
lp/registry/
Access to most attributes and to "partial" interfaces that were public
now requires the permission launchpad.View; the permission
launchpad.AnyPerson is replaced with launchapd.
(lp.services.
has a "shortcut" for the permission launchpad.
dedicated security adapters are looked up for this permission,
so the new rule "data for milestones of private product should only
be visible for person having a policy grant" cannot be implemented
with this permission.)
I also sorted the attributes requiring lp.View alphabetically.
lp/security.py:
two new adapters for IMilestone and the permissions lp.View and
lp.AnyAllowedPe
Both methods delegate the security check to the new method
Milestone.
lp/registry/
The new method userCanView(). The acutal permission check is done
by IProduct.
lp/registry/
Tests for the permissions.
The test class properties expected_
expected_
are acutally used for IMilestone.
The tests are similar to the test pattern I also used for the
security adapters of IProduct and ISpecification, so I moved the
common method checkPermissions() to lp.testing.
test:
./bin/test registry -vvt lp.registry.
no lint
| Abel Deuring (adeuring) wrote : | # |
Rick, thanks for the review.
Regarding #155:
153 + def userCanView(self, user):
154 + """See `IMilestone`."""
155 + # A database constraint ensures that either self.product
156 + # or self.distribution is not None.
157 + if self.product is None:
158 + # Distributions are always public, and so are their
159 + # milestones.
160 + return True
I think it does not matter effectively if we check against self.product is None or self.distribution is None because the DB constraint ensures that exactly one of self.distribution and self.product is None.
#328 is about arrtibutes that require other permissions that CHeckPublic or lp.View, which means the permissions lp.AnyPerson and lp.Edit. (Note the "continue" in line 327)

Thanks Abel, looks good with some typo nitpicks and one question for you.
#155 Should the check here be against distributions directed instead of indirectly using product?
#260 Typo in assertAccessAut horzized (Authorized) [ok, find and repeat throughout here]
#264 Typo implenet (implement)
#285 "may not"
#302 "have access to public"
#328 I would have expected the user to have access to the information on a public milestone? Is this an incorrect assumption? I guess not since they'd not have access to launchpad.View permissions.