Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-81326

The actual HasPermission implementation is fully coupled with the different APIs

    Details

      Description

      HasPermission is fully coupled with the different APIs that use it, since it contains methods for checking permissions for different types of models: forAddingEntries, forAddingRootJournalArticle, forAddingUsers, forDeletingLayouts...

      This approach is neither modular nor scalable, since classes inside the portal module in headless-apio should be usefull for every API and coupled as possible with the different implementations.

      The ideal solution would be to have a fully generic HasPermission interface with methods that allow API developers to check for CRUD permissions for any model. Along with this, instead of providing an implementation in the portal-apio-impl module, each API module should implement their own HasPermission and override just the methods that will be used (in order to achieve this the HasPermission interface should contain only default methods).

      Then, for requesting a specific HasPermission implementation we could follow a similar approach like with the ModelResourcePermission...

      @Component(property = "model.class.name=com.liferay.portal.kernel.repository.model.FileEntry")
      public class FileEntryHasPermissionImpl implements HasPermission
      

      ..for declaring it, and...

      @Reference(target = "(model.class.name=com.liferay.portal.kernel.repository.model.FileEntry)")
      private HasPermission _hasPermission;
      

      With this approach, using HasPermission methods would be as simple as:

      return builder.addGetter(
      	_blogsService::getEntry
      ).addRemover(
      	idempotent(_blogsService::deleteEntry), _hasPermission::forDeleting
      ).addUpdater(
      	this::_updateBlogsEntry, _hasPermission::forUpdating,
      	BlogPostingForm::buildForm
      ).build();
      

        Attachments

          Activity

            People

            Assignee:
            alejandro.hernandez Alejandro Hernandez (Inactive)
            Reporter:
            alejandro.hernandez Alejandro Hernandez (Inactive)
            Participants of an Issue:
            Recent user:
            Rubén Heras
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              2 years, 28 weeks, 1 day ago

                Packages

                Version Package
                7.1.0 Beta 2
                7.1.X
                Master