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

Add Announcement read permissions and (possibly) attach announcementCreatePermission to the CategoriesPage element #190

Open
elaine-mattos opened this issue Dec 11, 2023 · 1 comment

Comments

@elaine-mattos
Copy link

elaine-mattos commented Dec 11, 2023

Hi!

thanks for the awesome plugin as it'll save us a considerable amount of time.

However, I am missing an announcementReadPermission, a read permission to the Announcements.
This would be helpful preventing guest users from creating/updating/deleting announcemnts, while still being able to view them.

Also, even if a user is not able to create new announcements, they would still be able to create categories. Would it be possible to link the announcementCreatePermission to the CategoriesPage element?
Another possible solution would be to expose the CategoriesPage so that the users of your plugin could attach any permissions they judge interesting...

Please let me know if I can help in any way! :)

@jiteshy
Copy link

jiteshy commented Jan 3, 2024

As per my understanding, a separate read permission is not required. Permissions framework allows specific features on a page to be restricted and that's how announcements page is built. Only the action buttons are removed/disabled if user does not have proper access.

Create, update & delete actions can be restricted with below permissions. Users not belonging to backstageAdminGroup can still see the announcements.

if (
  isPermission(request.permission, announcementCreatePermission) ||
  isPermission(request.permission, announcementUpdatePermission) ||
  isPermission(request.permission, announcementDeletePermission)
) {
  if (user?.identity.ownershipEntityRefs.includes(this.config.getConfig('permission').getString('backstageAdminGroup'))) {
     return { result: AuthorizeResult.ALLOW };
  }
  return { result: AuthorizeResult.DENY };
}

Do agree on the second point though. Categories page needs to be restricted for read only users. IMO, the categories button on the announcements page & the route itself can be restricted as I don't see a use case where category list will be of value to read only users.

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

No branches or pull requests

2 participants