REST endpoint to get user permissions?

How can my server for a Connect add-on determine what permissions a user has? I'm looking for ADMINISTER specifically, but it's unlikely to be right-specific.

I found two options, none of which seems ideal:

  • /rest/api/2/user/permission/search - according to docs it requires "admin" to access, which is way too strong a scope to ask for an add-on that claims to never ever even write to JIRA.
  • /rest/api/2/mypermissions - requires ACT_AS_USER, which seems pretty strong as well (permission to perform any action on behalf of any user? ouch!).

Am I missing something? Are these the only options?

1 answer

0 vote
Stephen Deutsch Community Champion Jul 17, 2017

I would recommend skipping the REST API completely, and use conditions to determine that:

https://developer.atlassian.com/static/connect/docs/latest/concepts/conditions.html

What you can do is to have 2 different entry points into whatever webItem/webPanel you are providing, and either separate it into different files (if you are referring to html files) or use the same base URL and include different query parameters in each one. One would check whether the user is admin, and the other one would check the same condition, but with invert:true.

So for example, the one with admin permission would point to:

/path-to-my-addon?isAdmin=true&issue=...

and the other inverted condition would point to:

/path-to-my-addon?isAdmin=false&issue=...

and then you can just read it out of the query parameters.

Stephen Deutsch Community Champion Jul 17, 2017

Of course, this only works if you are doing something that interacts with the user in the browser and is going to present the information right away. If it's reacting to a webhook or something like that, then you probably wouldn't be able to use what I mentioned. In that case, a little bit more information about your use case would be required.

Thanks, but this is pretty weak security. You can't really trust requests coming from the client, assuming that they have always been sent by your app, properly validated on the client side, etc.

Stephen Deutsch Community Champion Jul 17, 2017

I do see your point. If you are using JWT authentication for the requests, though, then you can validate that the requests haven't been tampered with, I think.

Perhaps there is another way to get this information; I'll take another look.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,181 views 13 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot