Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-20907: Introduce the notion of required rights #3285

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

michitux
Copy link
Contributor

@michitux michitux commented Jul 19, 2024

Jira URL

https://jira.xwiki.org/browse/XWIKI-20907

Changes

Description

  • Add a new flag to XWikiDocument if required rights shall be enforced.
  • Add the new flag to the filter stream and XAR APIs, increase the XAR version and adapt tests.
  • Add the new flag to the REST API.
  • Add the new flag to the edit form to support updating it.
  • Add a DocumentRequiredRightsManager API to allow getting the required rights that are set on a document.
  • Add a DocumentAuthorizationManager to check rights using required rights.
  • Restrict edit right to users that have all required rights.

TODO:

  • Add tests
  • Fix the resolving of implied rights
  • Add at least some UI, even if initially only for advanced users
  • Integrate required right checking into the contextual authorization manager for script and programming right.
  • Change as many existing right checks as possible to take document rights into account (e.g., UIX, translations, …)
  • Try to find a way to take required rights into account when saving documents with script rights
  • Address the remaining TODOs in the new code
  • Add a cache for required rights (in DocumentRequiredRightsManager)
  • Change the versions to 16.9.0RC1 as this is not ready for 16.6.0.
  • Add a mandatory class initializer for the XWiki.RequiredRightClass

Clarifications

Screenshots & Video

Executed Tests

Ran tests on all modules with code changes without quality profile (coverage is not met currently, this will be fixed).

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • None, this is a quite breaking new feature.

<revapi.differences>
<justification>Change in generated class of the REST model to add the
enforceRequiredRights property.</justification>
<criticality>highlight</criticality>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like an allowed to me (I don't see what this change could really break in practice).

* @return {@code true} if required rights defined in a {@code XWiki.RequiredRightClass} object shall be
* enforced, meaning that editing will be limited to users with these rights and content of this document can't
* use more rights than defined in the object, {@code false} otherwise
* @since 16.6.0RC1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will definitely not go in 16.6.0RC1, but anyway hard to tell right now what will be the version.

* Add a new flag to XWikiDocument if required rights shall be enforced.
* Add the new flag to the filter stream and XAR APIs, increase the XAR
  version and adapt tests.
* Add the new flag to the REST API.
* Add the new flag to the edit form to support updating it.
* Add a DocumentRequiredRightsManager API to allow getting the required
  rights that are set on a document.
* Add a DocumentAuthorizationManager to check rights using required
  rights.
* Restrict edit right to users that have all required rights.
* Add a test for DocumentRequiredRightsReader.
* Fix entity type computation.
* Add the enforce required rights flag to the document merge.
* Add tests to the authorization modules.
* Integrate required rights into the authorization integration test
frameworks.
* Integrate required rights into the contextual authorization manager.
* Start migrating to DocumentAuthorizationManager where necessary.
* Add DocumentAuthorizationManager to MockitoOldcore.
* Clone the document before setting the enforce required rights property
 in the Document script api.
* Complete incomplete comment in the AuthorizationManager.
* Gracefully handle checking rights when the passed document reference
is null.
* Use the document authorization manager in wiki UI extensions.
* Fix tests.
* Use the document authorization manager in more places.
* Adapt tests to the document authorization manager.
* ContextualAuthorizationManager: Deny access when required rights
cannot be loaded.
* Fix checkstyle in WikiUIExtensionComponentBuilder.
* Introduce a helper in XWikiContext to get the secure document.
* AuthServiceScriptService: use the document authorization manager.
* Move DocumentRequiredRightsReader to oldcore so it can be used in
  oldcore.
* Check rights when modifying documents or objects and when saving
  documents.
* Remove the analyzer for the required right object as it doesn't make
sense to take the object into consideration if this is basically where
we store the result of the analysis.
* Change the entity type of programming right in the required rights
analysis result to be `null`, i.e., the farm as programming right only
exists on the farm level. Adapt the tests that expected a different
value.
* Fix page tests by moving DefaultDocumentRequiredRightsManager to
  oldcore so the implementation is available to tests that use the
  Document script API.
* Replace the XWiki.RequiredRightClass document by a mandatory document
  initializer.
* Fix checkAccess in DocumentAuthorizationManager in the case of no
context document.
* WIP UI prototype.
* Add a method to api.Document to get the required rights.
* Add a script service for required rights.
* Add a way to convert a RequiredRight to a DocumentRequiredRight.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants