开发者

Can the JIRA SOAP api be used to determine whether a given user can view a given record?

开发者 https://www.devze.com 2023-02-23 08:38 出处:网络
I\'d like to be able to do something like this: #!/usr/bin/python if jira.user_has_permission(\'jsmith\', \'JIRA-123\'):

I'd like to be able to do something like this:

#!/usr/bin/python
if jira.user_has_permission('jsmith', 'JIRA-123'):
    print '%s has permis开发者_如何学编程sion to view %s' % (user, record)
else:
    print '%s does not have permission to view %s' % (user, record)

How can I implement jira.user_has_permission()?

Note: I'm looking for the ability to determine whether a user other than the user who is accessing the API has permission to view a given record.

Edit: I'm also open a solution that tells me whether the user has permission to view records inside of a given project. I tried using getProjectByKey, followed by getProjectWithSchemesById, but was not able to obtain the user information that I needed.


It's long-winded with the standard API but here you go.

getProjectWithSchemesById gives you a RemoteProject object. Probably has to be invoked by a user with jira-admin permissions. Note that getProjectByKey does not set the permission scheme in the value returned but is a handy way to get the project id to use in getProjectWithSchemesById.

The RemoteProject object from getProjectWithSchemesById has a getPermissionScheme method that returns a RemotePermissionScheme object.

The RemotePermissionScheme object has a getRemoteEntries method

The resulting array of RemoteEntries is what you need to iterate over to look for the Browse permission and which users and groups have it.

~Matt


The soap operation getIssue will throw a RemotePermissionException http://docs.atlassian.com/rpc-jira-plugin/latest/com/atlassian/jira/rpc/exception/RemotePermissionException.html when a user is trying to access a permission she shouldn't access.

Not sure how this is done in python, but I'm sure there should be a way to catch the exception in your method.

Francis

0

精彩评论

暂无评论...
验证码 换一张
取 消