Merge lp:~wgrant/launchpad/ssh-bugactivity-anon into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 17998
Proposed branch: lp:~wgrant/launchpad/ssh-bugactivity-anon
Merge into: lp:launchpad
Diff against target: 97 lines (+24/-3)
4 files modified
lib/lp/bugs/security.py (+14/-0)
lib/lp/bugs/stories/webservice/xx-bug.txt (+3/-1)
lib/lp/registry/stories/webservice/xx-person.txt (+2/-2)
lib/lp/security.py (+5/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/ssh-bugactivity-anon
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+291613@code.launchpad.net

Commit message

Make ISSHKey and IBugActivity records visible to anonymous API requests where appropriate.

Description of the change

Make ISSHKey and IBugActivity records visible to anonymous API requests where appropriate.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/security.py'
2--- lib/lp/bugs/security.py 2016-02-04 12:45:38 +0000
3+++ lib/lp/bugs/security.py 2016-04-12 11:05:49 +0000
4@@ -12,6 +12,7 @@
5 DelegatedAuthorization,
6 )
7 from lp.bugs.interfaces.bug import IBug
8+from lp.bugs.interfaces.bugactivity import IBugActivity
9 from lp.bugs.interfaces.bugattachment import IBugAttachment
10 from lp.bugs.interfaces.bugnomination import IBugNomination
11 from lp.bugs.interfaces.bugsubscription import IBugSubscription
12@@ -158,6 +159,19 @@
13 bugattachment, bugattachment.bug)
14
15
16+class ViewBugActivity(DelegatedAuthorization):
17+ """Security adapter for viewing a bug activity record.
18+
19+ If the user is authorized to view the bug, they're allowed to view the
20+ activity.
21+ """
22+ permission = 'launchpad.View'
23+ usedfor = IBugActivity
24+
25+ def __init__(self, bugactivity):
26+ super(ViewBugActivity, self).__init__(bugactivity, bugactivity.bug)
27+
28+
29 class ViewBugSubscription(AnonymousAuthorization):
30
31 usedfor = IBugSubscription
32
33=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
34--- lib/lp/bugs/stories/webservice/xx-bug.txt 2016-01-26 15:47:37 +0000
35+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2016-04-12 11:05:49 +0000
36@@ -2108,7 +2108,7 @@
37
38 >>> from lazr.restful.testing.webservice import (
39 ... pprint_collection, pprint_entry)
40- >>> activity = webservice.get(
41+ >>> activity = anon_webservice.get(
42 ... bug_one['activity_collection_link']).jsonBody()
43 >>> pprint_collection(activity)
44 next_collection_link: u'http://.../bugs/1/activity?ws.size=5&memo=5&ws.start=5'
45@@ -2116,6 +2116,8 @@
46 start: 0
47 total_size: 24
48 ...
49+ message: u"Decided problem wasn't silly after all"
50+ ...
51
52 >>> bug_nine_activity = webservice.get(
53 ... "/bugs/9/activity").jsonBody()
54
55=== modified file 'lib/lp/registry/stories/webservice/xx-person.txt'
56--- lib/lp/registry/stories/webservice/xx-person.txt 2016-01-26 15:47:37 +0000
57+++ lib/lp/registry/stories/webservice/xx-person.txt 2016-04-12 11:05:49 +0000
58@@ -193,7 +193,7 @@
59 >>> sshkeys = sample_person['sshkeys_collection_link']
60 >>> print sshkeys
61 http://.../~ssh-user/sshkeys
62- >>> print_self_link_of_entries(webservice.get(sshkeys).jsonBody())
63+ >>> print_self_link_of_entries(anon_webservice.get(sshkeys).jsonBody())
64
65 Let's give "ssh-user" a key via the back door of our internal Python APIs.
66 This setting of the ssh key should trigger a notice that the key has been
67@@ -215,7 +215,7 @@
68 Now when we get the sshkey collection for 'sssh-user' again, the key should
69 show up:
70
71- >>> keys = webservice.get(sshkeys).jsonBody()
72+ >>> keys = anon_webservice.get(sshkeys).jsonBody()
73 >>> print_self_link_of_entries(keys)
74 http://.../~ssh-user/+ssh-keys/...
75
76
77=== modified file 'lib/lp/security.py'
78--- lib/lp/security.py 2016-02-05 14:34:51 +0000
79+++ lib/lp/security.py 2016-04-12 11:05:49 +0000
80@@ -165,6 +165,7 @@
81 IHasOwner,
82 )
83 from lp.registry.interfaces.sourcepackage import ISourcePackage
84+from lp.registry.interfaces.ssh import ISSHKey
85 from lp.registry.interfaces.teammembership import (
86 ITeamMembership,
87 TeamMembershipStatus,
88@@ -2918,6 +2919,10 @@
89 usedfor = IGPGKey
90
91
92+class ViewSSHKey(AnonymousAuthorization):
93+ usedfor = ISSHKey
94+
95+
96 class ViewIrcID(AnonymousAuthorization):
97 usedfor = IIrcID
98