Wiki source code of Required Rights of a Page
Last modified by Eleni Cojocariu on 2026/08/31 14:00
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
![]() |
3.1 | 1 | A page that contains a [[script macro>>doc:extensions:Extension.Script Macro]], that is a UI extension, or that holds anything else needing a right in order to run, is said to require that right. XWiki does not check the reader for it: it checks the last author of the content for scripts in the content and the title, and the effective metadata author for objects and their content. |
| 2 | |||
| 3 | That has consequences an administrator has to expect. Editing a page can start executing scripts that never ran before, when the new author has more rights than the previous one, or break the page when the new author lacks a right it needs. Changing the rights of a user, or deleting that user, moves every page they last saved along with them. | ||
| 4 | |||
| 5 | == Enforcing the required rights == | ||
| 6 | |||
| 7 | Rather than leaving the rights of a page to follow its last author, an administrator can declare which rights the page needs and enforce them, as described in [[Enforce the Required Rights of a Page>>doc:documentation.xs.admin.rights.required-rights.enforce.WebHome]]. Enforcing them does two things: it denies edit right to users who do not hold the required rights, so that they cannot break the page, and it denies "Script", wiki "Admin" and "Program" right unless that right was explicitly declared. The second half is what limits the damage: a user with more rights editing the page no longer grants those rights to content that was never meant to have them, which also blocks the exploitation of some security vulnerabilities. | ||
| 8 | |||
| 9 | A page with enforced required rights carries an [[XObject>>doc:documentation.xs.dev.data-model.x-objects.WebHome]] of type ##XWiki.RequiredRightClass##, which makes such pages easy to find. | ||
| 10 | |||
| 11 | == How XWiki decides which rights a page needs == | ||
| 12 | |||
| 13 | Enforcing a right does not require guessing it. XWiki analyses the page and all its translations, looking at every macro and object that might need a right, and rates each finding as "Required", "Might be required", "Might be enough" or "Enough". The uncertainty is real rather than a shortcoming of the analysis: a [[Velocity macro>>doc:extensions:Extension.Velocity Macro]] certainly needs "Script" right, while whether the code inside it needs "Program" right cannot be decided without reading it. That is what the "Analysis Details" section of the review dialog is for. | ||
| 14 | |||
| 15 | == When the enforced rights no longer match the content == | ||
| 16 | |||
![]() |
6.1 | 17 | Editing the content of a page can leave its enforced rights wrong in either direction, so XWiki keeps checking them and reports four situations: a right is definitely missing, a right might be missing, a right might no longer be needed, or a right is definitely no longer needed. Each of them is reported in the page information, to the users who may act on it: those who have edit right on the page and are either advanced users or hold "Script" right. The two messages about a missing right are shown only to those of them who also hold the right being suggested. |
![]() |
3.1 | 18 | |
![]() |
6.1 | 19 | When a right is definitely missing the page is likely to be seriously broken, so a warning is also displayed above the page itself, to the users who have edit right on the page and hold the missing right. |
![]() |
3.1 | 20 | |
| 21 | {{image reference="required-rights-warning.png" size="extra" alt="The warning displayed above a page whose required rights are missing"/}} |
