Skip to content

Commit e42d140

Browse files
author
Aurélien GASTON
committed
Fix authentication for some auth paths
fixes ovh#20
1 parent 3037170 commit e42d140

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/ovh.es5.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ var Ovh = function () {
5151
this.timeout = params.timeout;
5252
this.apiTimeDiff = params.apiTimeDiff || null;
5353
this.endpoint = params.endpoint || null;
54+
this.noAuthPaths = params.noAuthPaths || ['/auth/credential', '/auth/time'];
5455

5556
// Preconfigured API endpoints
5657
if (this.endpoint) {
@@ -363,7 +364,7 @@ var Ovh = function () {
363364
}
364365
}
365366

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

369370
// Sign request

lib/ovh.es6.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Ovh {
4343
this.timeout = params.timeout;
4444
this.apiTimeDiff = params.apiTimeDiff || null;
4545
this.endpoint = params.endpoint || null;
46+
this.noAuthPaths = params.noAuthPaths || ['/auth/credential', '/auth/time'];
4647

4748
// Preconfigured API endpoints
4849
if (this.endpoint) {
@@ -356,7 +357,7 @@ class Ovh {
356357
}
357358
}
358359

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

362363
// Sign request
@@ -487,4 +488,4 @@ class Ovh {
487488

488489
module.exports = function (params) {
489490
return new Ovh(params || {});
490-
};
491+
};

0 commit comments

Comments
 (0)