Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to check whether a user is an administrator in Connect?

Adrien Ragot 2
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 26, 2016

As an add-on developer, I want to let Confluence Cloud administrator edit the settings of my add-on if, and only if, they are administrators.

Is there any REST request I can perform to know whether they are admin? Among the ones I've seen in the documentation, there only hacks are available:

  • Check whether the user belongs to a group, assuming "administrators" will always contain the list of instance administrators (which is far from correct),
  • Trying to create a space – If successful, the user is admin.

A normal request at https://myinstance.atlassian.net/wiki/rest/api/user?username=test1 doesn't return the permissions:

{
type: "known",
username: "test1",
userKey: "ff808081400000000fe0f0e0ff",
profilePicture: {path: "/wiki/images/icons/profilepics/default.png",width: 48,height: 48,isDefault: true},
displayName: "Test 1 [Administrator]",
_links: {self: "https://playsql.atlassian.net/wiki/rest/experimental/user?key=ff808081400000000fe0f0e0ff"},
_expandable: {details: ""}
}

 

Thank you

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 27, 2016

Although it is difficult to figure out whether a user is admin via the REST API (or the JSON-RPC API for that matter), usually you restrict access in Connect by using Conditions, by which you can hide the entry point to the settings (hide the web-item, or you might be able to also do it for a dialog box?).

In this case, you would specifically use the user_is_admin condition (https://developer.atlassian.com/static/connect/docs/latest/concepts/conditions.html#common-conditions).

If that doesn't work for you, you might be able to do a workaround by creating an additional web-section that is displayed on the same page and which doesn't display any content (set height to 0px) but whose sole purpose is to send an AP.events message to your other iframe that says that the user is admin and is only activated when the user_is_admin condition passes.

Adrien Ragot 2
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2016

This is sad, but it seems to be the right answer. Thank you very much.

TAGS
AUG Leaders

Atlassian Community Events