Sudo for Jira

Jira's REST API has no built in support for allowing a user to take actions on behalf of another. This is problematic for environments where automated scripts are pulling data from other sources and taking action on events within Jira. An example is a script that watches a revision control repository, and logs work and transitions issues based on commands embedded in commit messages.

This plugin allows administrators to perform actions on behalf of others using the REST API.

Usage

To use this plugin simply add a "sudo" or "sudo-email" header to your request with the corresponding username or user email address of the user you want to perform the request on behalf of. If no user is found that matches the supplied sudo username or sudo email address, or if the user making the request is not an administrator, the request will be performed as normal based on the authenticated user.

*New as of July 2020 is strict mode. Strict mode is enabled by adding a "sudo-strict" header to the request with a value of "true". This is in addition to the "sudo" or "sudo-email" required header. When strict mode is enabled, any sudo request where the target user is not found will return with 404 Not Found result code, instead of performing the API request as the original user. Additionally, if a user attempts to perform a sudo request with strict mode on, that does not have permission to do so, they will receive a 403 Forbidden result code.

Examples

$ curl -u admin:admin -X POST -H "Content-Type: application/json" -H "sudo: jane" --data '{"timeSpent": "1h"}' \
> http://localhost:2990/jira/rest/api/2/issue/FB-1/worklog | python -m json.tool

$ curl -u admin:admin -X POST -H "Content-Type: application/json" -H "sudo-email: jane@doe.com" --data '{"timeSpent": "1h"}' \
> http://localhost:2990/jira/rest/api/2/issue/FB-1/worklog | python -m json.tool

$ curl -u admin:admin -X POST -H "Content-Type: application/json" -H "sudo-email: jane@doe.com" -H "sudo-strict: true" --data '{"timeSpent": "1h"}' \
> http://localhost:2990/jira/rest/api/2/issue/FB-1/worklog | python -m json.tool
        

Supported Versions

Sudo for Jira is currently known to work on the entire 6.x.x-8.x.x+ range of Jira versions.