Hi Andrew,
On 18 Apr 2016, at 19:32, Andrew Kuang
<afkuang(a)gmail.com> wrote:
Thank you for the responses, Vincent and Marius.
After playing around with the HTML macro, I came across a potential
solution. It appears that all the XWiki-created pages reside within certain
spaces (xwiki:Wiki, xwiki:WikiManager, etc). With that in mind, I was able
to prototype an override for the HTML macro that whitelisted specific wiki
spaces (Wiki, WikiManager, etc) and potentially lock down the creation/edit
of pages in those spaces to the Admin group. This way we would be able to
avoid conflicting with any existing Javascript usage while preventing
outside (non-admin) users from using JavaScript on their pages.
In the event that the page in question is not part of the whitelisted space
and contains Javascript, we would return an error block with an error
message instead of rendering the content passed into the HTML macro. I
wanted to get any input on if this is a viable solution or if there are any
crucial parts I may have overlooked that jeopardize this approach. Thank
you!
The main issue I can see is that XWiki extensions contribute pages in various spaces. For
example the Admin Application contributes pages in the XWiki space, while the FAQ
Application contributes pages in the FAQ and FAQCode spaces. So if one extension requires
javascript you’ll need to add those spaces to your whitelist.
Another option you have is to allow javascript when the last author of the page has
programming rights for example (this is the highest security level in XWiki) or even Admin
rights. Thus installed extensions would work since you install them with a user having
Admin rights at minimum.
To check for this is easy:
@Inject
private ContextualAuthorizationManager cam;
…
if (!cam.hasAccess(Right.PROGRAM, <current doc reference>) {…}
Hope it helps,
Thanks
-Vincent