Cannot clone nor push with http://username@stash:7990/scm
Symptoms
While running Stash connected to JIRA User Directory, it is not possible to clone nor push in the following combination:
git clone http://username@stash:7990/scm/ACME/acmerepo.git
Diagnosis
To simulate the request that Stash is making to JIRA and see what JIRA is returning:
Create a file named "post-data" with the following contents:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <password> <value></value> </password>
Run the following cURL command (from the directory where the file was created) with
<application-name>
and<application-password>
replaced with the application name and application password that Stash is using to connect to JIRA as a user directory:curl -v -X POST -H "Accept: application/xml" -H "Content-Type: application/xml" -u <application-name>:<application-password> https://www.acme.com/jira/rest/usermanagement/1/authentication?username=bbunny --data @post-data
If JIRA is integrated with IIS, the response should contain something like:
Server: Microsoft-IIS/7.5 ... X-Powered-By: ASP.NET
Cause
JIRA uses a 400 response code with a specific message in the body to indicate to Stash that authentication for a particular user has failed. In this case the response body and content-type are being mangled by IIS behavior.
This causes Stash to mis-parse the response from JIRA and fall over with a 500 error on the client.
Resolution
Edit the
web.config system.webServer
section and sethttpErrors existingResponse
attribute to "PassThrough":<system.webServer> ... <httpErrors existingResponse="PassThrough"></httpErrors> ... </system.webServer>
For more information check Integrating JIRA with IIS.