#12914 closed defect (fixed)
TOC Macro is not working for FullBlogPlugin if user has not WIKI_VIEW permission
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | lowest | Component: | TocMacro |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description
In the scenario where a user has BLOG_VIEW permission ( for FullBlogPlugin ) but not WIKI_VIEW permission, the TOC window in any blog post has no content.
The problem is that the code explicitly checks for WIKI_VIEW permission.
The fix is straight forward: check for either WIKI_VIEW or BLOG_VIEW.
Attachments (2)
Change History (9)
Changed 8 years ago by
Attachment: | my_patch_file.diff added |
---|
comment:2 follow-up: 4 Changed 8 years ago by
This could be a better approach, removing the specific BLOG permission from TOC macro:
As the TOC macro is used in an already protected element ( wiki, blog, whatever ... ), it doesn't make any sense to check the permissions for the TOC element itself, as it will not be displayed in the case that the user can not access the upper element.
So this solution is about completely remove the checking of the WIKI_VIEW permission. This way, the not nice referente to a permission belonging to other pluging ( like blog ) is not needed.
comment:3 Changed 8 years ago by
Owner: | set to Ryan J Ollos |
---|---|
Status: | new → accepted |
comment:4 follow-up: 5 Changed 8 years ago by
Replying to bitelxux@…:
As the TOC macro is used in an already protected element ( wiki, blog, whatever ... ), it doesn't make any sense to check the permissions for the TOC element itself, as it will not be displayed in the case that the user can not access the upper element.
TracFineGrainedPermissions checks need to be performed for the case that the TOC of another resource is being displayed. The TocMacro assumes that other resource is a wiki page.
The following might be the simplest change we could make to support your use case - displaying the TOC
for a blog post. It wouldn't fix all the issues with using TOC
in a blog post - displaying TOC
for another blog post still wouldn't work.
As you've suggested, the action should already have been checked for the resource on which the TOC
is used, so we could skip the permission check for that resource:
-
tractoc/macro.py
202 202 active = len(pagenames) > 1 203 203 for pagename in pagenames: 204 204 page_resource = resource(id=pagename) 205 if not 'WIKI_VIEW' in context.perm(page_resource): 206 # Not access to the page, so should not be included 205 if resource.id != pagename and \ 206 not 'WIKI_VIEW' in context.perm(page_resource): 207 # No access to the page, so should not be included 207 208 continue 208 209 if 'title_index' in params: 209 210 self._render_title_index(formatter, ol, page_resource,
comment:5 Changed 8 years ago by
Replying to rjollos:
Sounds good :-) That way in the use case where a user has access only to the blog will see the most common case.
comment:6 follow-up: 7 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
In 15937:
Proposed patch