Skip to content

Commit

Permalink
fixed url building & password encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Elizabeth Southerland authored and Elizabeth Southerland committed Jul 20, 2018
1 parent 751b435 commit a55cf6e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions c8y-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = function(RED) {

// Adding auth header // TODO: develop a more secure way to do this
if (this.config.user && this.config.password) {
var rawCreds = tenant + '/' + this.config.user + ':' + this.credentials.password;

var rawCreds = tenant + '/' + this.config.user + ':' + this.config.password;
var byteCreds = utf8.encode(rawCreds);
encodedCreds = base64.encode(byteCreds);
// Trim off trailing =
Expand Down Expand Up @@ -81,7 +82,7 @@ module.exports = function(RED) {

var respBody, respStatus;
var options = {
url: "https://" + domain + pathAndQuery,
url: "https://" + tenant + '.' + domain + pathAndQuery, // TODO: do this without SO MUCH concatenation, geez
headers: {
'Authorization': 'Basic ' + encodedCreds
}
Expand Down

0 comments on commit a55cf6e

Please sign in to comment.