Custom Global Permissions for Addon

We are currently in the process of developing our first JIRA Server add-on. In existing add-ons such as Tempo Timesheets, we’ve noted custom permission schemes being added into the JIRA Global Permissions admin panel which can be applied to groups and feel like this kind of setup would suit our addon.

After a few days of experimenting with API calls and even reading the JIRA source code, we are still stuck with trying to implement this custom global permission scheme. Does anyone have any experience in implementing custom global permissions schemes, or know any other resources we should be looking into?

Cheers

1 Like

Can you expand on where you’re running into issues? Is it getting the permission to show up or how to use it?

So we initially tried to create a new instance of GlobalPermissionType (GlobalPermissionType (Atlassian JIRA 7.0.8 API)) and then apply it to a user group via the GlobalPermissionManager (GlobalPermissionManager (Atlassian JIRA 7.0.8 API))

If this was done twice, an error was generated saying that the group already has the global permission. However, the global permissions did not appear in the JIRA admin panel. Is there something else that is needed to be done to have this appear in the admin panel so that admins can apply the permissions to groups via UI instead of programmatically?

All right here goes (shouldn’t be too long though).

In your atlassian-plugin.xml you’ll need to define your new permission type. Something like:

  <global-permission key="sample.custom.globalpermission"
                     i18n-name-key="sample.custom.globalpermission.name"
                     i18n-description-key="sample.custom.globalpermission.description"
                     anonymous-allowed="true"/>

where the i18n-* are keys that you place in the i18n properties file. The key attribute is something unique to the permission (make sure it has a prefix of your add-on in it).

Then in your code you’ll get a GlobalPermission Key through GlobalPermissionKey.of("sample.custom.globalpermission") and you can then do whatever you want to it.

An example of all of this is over at Bitbucket

Take a look at localhost:2990/jira/plugins/servlet/permissionservlet as you manipulate the global permission.

4 Likes

I’d actually found this out by examining the source code of JIRA, but thanks for the hint it’s exactly what we needed!