Skip to content

Commit

Permalink
Fix authentication for some auth paths
Browse files Browse the repository at this point in the history
fixes ovh#20
  • Loading branch information
Aurélien GASTON committed Sep 13, 2018
1 parent 64603b1 commit 2ff0280
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/ovh.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var Ovh = function () {
this.timeout = params.timeout;
this.apiTimeDiff = params.apiTimeDiff || null;
this.endpoint = params.endpoint || null;
this.noAuthPaths = params.noAuthPaths || ['/auth/credential', '/auth/time'];

// Preconfigured API endpoints
if (this.endpoint) {
Expand Down Expand Up @@ -363,7 +364,7 @@ var Ovh = function () {
}
}

if (path.indexOf('/auth') < 0) {
if (!this.noAuthPaths.includes(path)) {
options.headers['X-Ovh-Timestamp'] = Math.round(Date.now() / 1000) + this.apiTimeDiff;

// Sign request
Expand Down
5 changes: 3 additions & 2 deletions lib/ovh.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Ovh {
this.timeout = params.timeout;
this.apiTimeDiff = params.apiTimeDiff || null;
this.endpoint = params.endpoint || null;
this.noAuthPaths = params.noAuthPaths || ['/auth/credential', '/auth/time'];

// Preconfigured API endpoints
if (this.endpoint) {
Expand Down Expand Up @@ -356,7 +357,7 @@ class Ovh {
}
}

if (path.indexOf('/auth') < 0) {
if (!this.noAuthPaths.includes(path)) {
options.headers['X-Ovh-Timestamp'] = Math.round(Date.now() / 1000) + this.apiTimeDiff;

// Sign request
Expand Down Expand Up @@ -487,4 +488,4 @@ class Ovh {

module.exports = function (params) {
return new Ovh(params || {});
};
};

0 comments on commit 2ff0280

Please sign in to comment.