Skip to content
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

Write and read jwk_public_keys from Redis if Synchrnizer is enabled #93

Closed
wants to merge 1 commit into from
Closed
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
51 changes: 35 additions & 16 deletions lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,22 +402,41 @@ const processLoad = (config, keys, callback, useSynchronizer, redisClient) => {
}
},
function(cb) {
var opts = _.clone(options);
opts['url'] = config.edge_config.jwk_public_keys || null;
opts = enableTLS(config, opts);
request.get(opts, function(err, response, body) {
if (response && response.statusCode === 200) {
_loadStatus('jwk_public_keys', opts['url'],
err, response, body, cb);
} else {
response = {};
response.statusCode = 200;
body = null;
err = null;
_loadStatus('jwk_public_keys', opts['url'],
null, response, body, cb);
}
});
if (useSynchronizer || !config.edge_config.redisBasedConfigCache) {
var opts = _.clone(options);
opts['url'] = config.edge_config.jwk_public_keys || null;
opts = enableTLS(config, opts);
request.get(opts, function(err, response, body) {
if(useSynchronizer && !err && response && response.statusCode === 200) {
saveConfigToRedis(redisClient, globalOptions, config.edge_config.jwk_public_keys, body, 'jwk_public_keys', (err)=>{
if ( err ) {
writeConsoleLog('error',{component: CONSOLE_LOG_TAG_COMP}, 'error saving data to redis from %s', config.edge_config.jwk_public_keys, err);
return;
}
writeConsoleLog('info',{component: CONSOLE_LOG_TAG_COMP}, 'Saved data to redis from %s', config.edge_config.jwk_public_keys);
});
}
if (!config.edge_config.redisBasedConfigCache) {
if (response && response.statusCode === 200) {
_loadStatus('jwk_public_keys', opts['url'],
err, response, body, cb);
} else {
response = {};
response.statusCode = 200;
body = null;
err = null;
_loadStatus('jwk_public_keys', opts['url'],
null, response, body, cb);
}
}
});
}
if (config.edge_config.redisBasedConfigCache === true) { //retrieve info from redis db
getConfigFromRedis(redisClient, globalOptions, config.edge_config.jwk_public_keys, 'jwk_public_keys', function(err, body){
const response = err ? null : { statusCode: 200, statusMessage: 'Downloaded from redis' };
_loadStatus('jwk_public_keys', config.edgemicro.redisHost, err, response, body, cb);
});
}
}
], function(err, results) {
debug('error %s, proxies %s, products %s, jwt_public_key %s', err,
Expand Down