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-22683: Move org.xwiki.security.authorization.DefaultAuthorizationManager to internal package #3791

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

surli
Copy link
Member

@surli surli commented Jan 7, 2025

Jira URL

Changes

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

Description

  • Move DefaultAuthorizationManager to internal package
  • Expose some APIs that were package protected to make them public so that the component implementation can access them
  • Add a revapi ignore to explain the removed public API

Clarifications

Screenshots & Video

Executed Tests

Ran mvn clean install -Pquality on module xwiki-platform-security

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • No

…onManager to internal package

  * Move DefaultAuthorizationManager to internal package
  * Expose some APIs that were package protected to make them public so
    that the component implementation can access them
  * Add a revapi ignore to explain the removed public API
@surli surli self-assigned this Jan 7, 2025
Copy link
Contributor

@michitux michitux left a comment

Choose a reason for hiding this comment

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

I'm not convinced that just making all these methods on Right public is okay. They are clearly intentionally internal, as also stated by the documentation.

@@ -420,7 +420,7 @@ public static List<Right> getStandardRights()
*
* @since 13.5RC1
*/
void unregister()
public void unregister()
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be marked as @Unstable as this will be a new public API? Also, considering https://jira.xwiki.org/browse/XWIKI-21012, I'm wondering if it is really a good idea to expose this as a new public API.

Further, from what I can see, this would be the only method on Right that is dangerous, meaning that with this change, it wouldn't be safe anymore to expose a Right object in a script API. I can't find any place where Right is exposed in a script API, however, I actually wanted to do exactly this (expose Right objects in script APIs) for required rights.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I just found out that it is already possible to access Right instances with just script right. Making this method public means that any user with script right can unregister any right. I don't think this is a good idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for checking it, I agree it's probably not a good idea. But I'm not yet sure how to avoid this, creating a SecuredRight wrapper doesn't feel like the right way here.

@@ -206,7 +206,7 @@ public class Right implements RightDescription, Serializable, Comparable<Right>
* @param impliedByRights the already existing rights that imply this new right.
* @since 12.6
*/
Right(RightDescription description, Set<Right> impliedByRights)
public Right(RightDescription description, Set<Right> impliedByRights)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is in contradiction to the documentation of the method. Either, this method must be kept package-private or the documentation must be changed. To me, making this constructor public seems like a very important API change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting, I'm starting to wonder if the component implem wasn't public just because of this... I'm not a big fan of making this public but I'm not sure how to avoid it.

@@ -535,7 +535,7 @@ public int compareTo(Right other)
* @param description a right description to compare this right to.
* @return true if the right is equivalent to the provided description.
*/
boolean like(RightDescription description)
public boolean like(RightDescription description)
Copy link
Contributor

Choose a reason for hiding this comment

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

As for the other methods, I think this method should be marked as @Unstable as it is a new part of the public API. I don't see any problems with exposing this method, but I think it's documentation should be made clearer - why does this method exist and when should it be used as opposed to equals() or compareTo.

@surli surli marked this pull request as draft January 15, 2025 14:59
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