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

Failing at generating a QueryStringHash

UTurista September 3, 2015

Following the documentation, to authenticate a JIRA message we need to check if the query was not tempered by creating a hash of it and comparing it with the one in JWT Token.

Unfortunately I'm unable to create said hash, even after following the instructions.

 

My addon-descriptor has the following structure:

{
 "name": "JiraMantisInSync",
 "description": "JiraMantisInSync",
 "key": "xx.xxxxxxx.jira",
 "baseUrl": "http://localhost/mantisbt-1.2.19/",
 "vendor": {
    "name": "xxxx",
    "url":  "-xxx"
  },
  "authentication": {
    "type": "jwt"
  },
  "lifecycle": {
    "installed": "plugin.php?page=JiraMantisInSync/install",
    "uninstalled": "plugin.php?page=JiraMantisInSync/uninstall",
    "enabled": "plugin.php?page=JiraMantisInSync/enable"
  },
  "apiVersion": 1
 }

 

If I understood correctly the hash of the query when we're uninstalling the addon should be:

$method = 'POST';
$url = '/plugin.php';
 
//$_SERVER['QUERY_STRING'] = "page=JiraMantisInSync/uninstall?user_key=admin"
$query = 'page=JiraMantisInSync%2Funinstall&user_key=admin'; 
 
$queryString = $method . '&' . $url . '&' . $query 

$qsh =  hash('sha256', $queryString );

 

But so far neither this or other alternatives have been giving the expected value.

Any suggestions on what am I missing?

 

EDIT:

The expected hash  is:

cb83abdcc4200b537fbce4ea7552f70884484c87ab9d2568a87cf90a63578675

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Volodymyr Krupach
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.
September 3, 2015

Do not you need to "percent encode" _ from user_key?

UTurista September 3, 2015

Not that I'm aware of, Wikipedia does not classifies it has reserved character and JIRA's documentation does not considers it a special case. (Tested either way still didn't work)

TAGS
AUG Leaders

Atlassian Community Events