alexkvak / teamcity-slack

TeamCity Slack plugin
MIT License
124 stars 23 forks source link

Usage rights should be based on permission "Edit Project", not on group id "PROJECT_ADMIN" #136

Open freakalot opened 2 years ago

freakalot commented 2 years ago

Hi, we are using the plugin since a while and it works great so far. One thing which still bothers us is the problem that only sysadmins can see the slack tab in the project and therefore only they are able to configure it. Isn't there a way to make this tab with edit rights available to specific users?

alexkvak commented 2 years ago

Hi, this tab should be available for project admins

freakalot commented 2 years ago

Hi Alex, thanks for your quick response. Do you know which specific permission is responsible for this? We have set up our own roles and therefore don't use the predefined ones.

alexkvak commented 2 years ago

That's how it looks like in UI

изображение

Group can be created here /admin/admin.html?item=groups

freakalot commented 2 years ago

Ok, but I need to know which permission is responsible for this. As I said, we don't use the predefined Project administrator role but created a new one. Now I need to know which of the permissions I need to assign to our role that they can see the slack tab: image

alexkvak commented 2 years ago

Unfortunately this check is based on role not permission com/fpd/teamcity/slack/PermissionManager.scala:54

freakalot commented 2 years ago

I see, but I think this is a bug, as the roles in Teamcity are just a collection of permissions and can be customized. I don't think that you should hardcode the rights to a default role. Not sure if its possible to create a new permission with a plugin, but it should either be linked to a permission, or you need to be able to overwrite the role for the plugin.

It is actually done properly in the same file in line 29:


private def isAdmin(request: Request): Boolean =
    request.exists(
      _.isPermissionGrantedGlobally(Permission.CHANGE_SERVER_SETTINGS)
    )```
alexkvak commented 2 years ago

AFAIK there is no way to create custom permission, you can assign to role only predefined permissions

freakalot commented 2 years ago

Even in this case, the correct sollution would be to check if the user has the "Edit project" permission to be able to use the slack settings. Not the name of a role.

alexkvak commented 2 years ago

It makes sense. And it's easy to implement.

But there is only one thing that should be carefully handled — is seems that is should be the major version change.