Skip to content

Commit 2925b9c

Browse files
committed
Fixing OAuth support as Atlassian provider only supports RSA-SHA1
1 parent 6429788 commit 2925b9c

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

lib/jira.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
// * `Jira API Version<string>`: Known to work with `2` and `2.0.alpha1`
5050
// * `verbose<bool>`: Log some info to the console, usually for debugging
5151
// * `strictSSL<bool>`: Set to false if you have self-signed certs or something non-trustworthy
52-
// * `oauth`: A dictionary of `consumer_key`, `consumer_secret`, `access_token` and `access_token_secret` to be used for OAuth authentication.
52+
// * `oauth`: A dictionary of `consumer_key`, `consumer_secret`, `access_token` and `access_token_secret` to be used for OAuth authentication. Optional signature_method, but Atlassian uses RSA-SHA1.
5353
// * `base`: Add base slug if your JIRA install is not at the root of the host
5454
//
5555
// ## Implemented APIs ##
@@ -129,8 +129,7 @@
129129
// * _0.0.3 Added APIs and Docco documentation_
130130
// * _0.0.2 Initial version_
131131
var url = require('url'),
132-
logger = console,
133-
OAuth = require("oauth");
132+
logger = console;
134133

135134

136135
var JiraApi = exports.JiraApi = function(protocol, host, port, username, password, apiVersion, verbose, strictSSL, oauth, base) {
@@ -182,7 +181,8 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
182181
consumer_key: oauth.consumer_key,
183182
consumer_secret: oauth.consumer_secret,
184183
token: oauth.access_token,
185-
token_secret: oauth.access_token_secret
184+
token_secret: oauth.access_token_secret,
185+
signature_method: oauth.signature_method || 'RSA-SHA1'
186186
};
187187
} else if(this.username && this.password) {
188188
options.auth = {
@@ -1268,7 +1268,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
12681268

12691269
});
12701270
};
1271-
1271+
12721272
// ## Add component to Jira ##
12731273
// ### Takes ###
12741274
//
@@ -1289,29 +1289,29 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
12891289
json: true,
12901290
body: component
12911291
};
1292-
1292+
12931293
this.doRequest(options, function (error, response, body) {
1294-
1294+
12951295
if (error) {
12961296
callback(error, null);
12971297
return;
12981298
}
1299-
1299+
13001300
if (response.statusCode === 400) {
13011301
callback(body);
13021302
return;
13031303
}
1304-
1304+
13051305
if ((response.statusCode !== 200) && (response.statusCode !== 201)) {
13061306
callback(response.statusCode + ': Unable to connect to JIRA during search.');
13071307
return;
13081308
}
1309-
1309+
13101310
callback(null, body);
13111311

13121312
});
13131313
};
1314-
1314+
13151315
// ## Delete component to Jira ##
13161316
// ### Takes ###
13171317
//
@@ -1331,19 +1331,19 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
13311331
followAllRedirects: true,
13321332
json: true
13331333
};
1334-
1334+
13351335
this.doRequest(options, function (error, response) {
1336-
1336+
13371337
if (error) {
13381338
callback(error, null);
13391339
return;
13401340
}
1341-
1341+
13421342
if (response.statusCode === 204) {
13431343
callback(null, "Success");
13441344
return;
13451345
}
1346-
1346+
13471347
callback(response.statusCode + ': Error while deleting');
13481348

13491349
});
@@ -1656,7 +1656,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
16561656
callback("Invalid Fields: " + JSON.stringify(body));
16571657
return;
16581658
};
1659-
1659+
16601660
callback(response.statusCode + ': Error while adding comment');
16611661
});
16621662
};

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
}
2424
],
2525
"dependencies": {
26-
"request": "<2.16.0",
27-
"oauth": "^0.9.11"
26+
"request": "^2.69.0"
2827
},
2928
"scripts": {
3029
"test": "grunt test"

0 commit comments

Comments
 (0)