Skip to content

Commit

Permalink
create jwksClient in the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
luisrudge committed Sep 24, 2018
1 parent c514e61 commit 6d9f6b6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/auth/OAUthWithIDTokenValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ var OAUthWithIDTokenValidation = function(oauth, options) {
this.clientSecret = options.clientSecret;
this.domain = options.domain;
this.supportedAlgorithms = options.supportedAlgorithms || ['HS256', 'RS256'];
this._jwksClient = jwksClient({
jwksUri: 'https://' + options.domain + '/.well-known/jwks.json'
});
};

/**
Expand All @@ -57,9 +60,7 @@ OAUthWithIDTokenValidation.prototype.create = function(params, data, cb) {
if (header.alg === 'HS256') {
return callback(null, Buffer.from(_this.clientSecret, 'base64'));
}
jwksClient({
jwksUri: 'https://' + _this.domain + '/.well-known/jwks.json'
}).getSigningKey(header.kid, function(err, key) {
_this._jwksClient.getSigningKey(header.kid, function(err, key) {
if (err) {
return callback(err);
}
Expand Down

0 comments on commit 6d9f6b6

Please sign in to comment.