Skip to content

Fixing OAuth support as Atlassian provider only supports RSA-SHA1 #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions lib/jira.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// * `Jira API Version<string>`: Known to work with `2` and `2.0.alpha1`
// * `verbose<bool>`: Log some info to the console, usually for debugging
// * `strictSSL<bool>`: Set to false if you have self-signed certs or something non-trustworthy
// * `oauth`: A dictionary of `consumer_key`, `consumer_secret`, `access_token` and `access_token_secret` to be used for OAuth authentication.
// * `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.
// * `base`: Add base slug if your JIRA install is not at the root of the host
//
// ## Implemented APIs ##
Expand Down Expand Up @@ -129,8 +129,7 @@
// * _0.0.3 Added APIs and Docco documentation_
// * _0.0.2 Initial version_
var url = require('url'),
logger = console,
OAuth = require("oauth");
logger = console;


var JiraApi = exports.JiraApi = function(protocol, host, port, username, password, apiVersion, verbose, strictSSL, oauth, base) {
Expand Down Expand Up @@ -182,7 +181,8 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
consumer_key: oauth.consumer_key,
consumer_secret: oauth.consumer_secret,
token: oauth.access_token,
token_secret: oauth.access_token_secret
token_secret: oauth.access_token_secret,
signature_method: oauth.signature_method || 'RSA-SHA1'
};
} else if(this.username && this.password) {
options.auth = {
Expand Down Expand Up @@ -1268,7 +1268,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor

});
};

// ## Add component to Jira ##
// ### Takes ###
//
Expand All @@ -1289,29 +1289,29 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
json: true,
body: component
};

this.doRequest(options, function (error, response, body) {

if (error) {
callback(error, null);
return;
}

if (response.statusCode === 400) {
callback(body);
return;
}

if ((response.statusCode !== 200) && (response.statusCode !== 201)) {
callback(response.statusCode + ': Unable to connect to JIRA during search.');
return;
}

callback(null, body);

});
};

// ## Delete component to Jira ##
// ### Takes ###
//
Expand All @@ -1331,19 +1331,19 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
followAllRedirects: true,
json: true
};

this.doRequest(options, function (error, response) {

if (error) {
callback(error, null);
return;
}

if (response.statusCode === 204) {
callback(null, "Success");
return;
}

callback(response.statusCode + ': Error while deleting');

});
Expand Down Expand Up @@ -1656,7 +1656,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
callback("Invalid Fields: " + JSON.stringify(body));
return;
};

callback(response.statusCode + ': Error while adding comment');
});
};
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
}
],
"dependencies": {
"request": "<2.16.0",
"oauth": "^0.9.11"
"request": "^2.69.0"
},
"scripts": {
"test": "grunt test"
Expand Down