Rate this page:
Jira 4.1 and later.
Jira 4.1 and later employs a token authentication mechanism which is utilised whenever Jira actions are performed either through link request or form submission. This provides Jira with a means to validate the origin and intent of the request, thus adding an additional level of security against XSRF (Cross-site request forgery). While the core Jira product and its bundled plugins use this token handling mechanism by default, non-bundled plugins or those developed by third parties may not.
This document provides instructions to Jira plugin developers on how to incorporate this token handling mechanism into Jira plugins.
Jira 4.1 requires that WebWork actions possess tokens, which are then verified when the form is submitted back to the Jira server. This is an "opt in" mechanism, whereby actions must declare that they require a token to be present in the request.
The following subsections provide details on how to protect code against XSRF by implement form token handling into your Jira plugin.
Please be aware that once form token handling has been implemented into a Jira plugin:
To enable xsrf token checking for a particular Action class
@com.atlassian.jira.security.xsrf.RequiresXsrfCheckannotation to this method
The token is included by default when using a
The token can be included into your own JSPs that don't use jiraforms, by adding the following code:
<webwork:component name="'atl_token'" value="/xsrfToken" template="hidden.jsp"/>
The following code can be added to Velocity Templates:
<input type="hidden" name="atl_token" value="$atl_token" />
You can do the following in JSPs:
or Velocity Templates:
To get hold of the current user's token, you will need to make the following call:
import com.atlassian.jira.security.xsrf.XsrfTokenGenerator; XsrfTokenGenerator xsrfTokenGenerator = ComponentManager.getComponentInstanceOfType(XsrfTokenGenerator.class); String token = xsrfTokenGenerator.generateToken(request);
Scripts that access Jira remotely may have trouble acquiring or returning a security token, or maintaining an HTTP session with the server. There is a way for scripts to opt out of token checking by providing the following HTTP header in the request:
XSRF protection in Confluence.
For more information, refer to the Open Web Application Security Project page.
Rate this page: