apigee/microgateway-config

The jwk_public_keys configuration is not stored and fetched from Synchronizer/Redis

Opened this issue · 0 comments

imesh commented

Problem

If Synchronizer is enabled in the Microgateway, jwt_public_key configuration is managed by the Synchronizer using Redis:

function(cb) {
            if ( useSynchronizer || !config.edge_config.redisBasedConfigCache ) {
                var opts = _.clone(options);
                opts['url'] = config.edge_config.jwt_public_key;            
                opts = enableTLS(config, opts);
                request.get(opts, function(err, response, body) {
                    if(useSynchronizer && !err && response && response.statusCode === 200){
                        saveConfigToRedis(redisClient, globalOptions, config.edge_config.jwt_public_key, body, 'jwt_public_key', (err)=>{
                            if ( err ) {
                                writeConsoleLog('error',{component: CONSOLE_LOG_TAG_COMP}, 'error saving data to redis from %s', config.edge_config.jwt_public_key, err);
                                return;
                            }
                            writeConsoleLog('info',{component: CONSOLE_LOG_TAG_COMP}, 'Saved data to redis from %s', config.edge_config.jwt_public_key);
                        });
                    }
                    if ( !config.edge_config.redisBasedConfigCache) {
                        _loadStatus('jwt_public_key', config.edge_config.jwt_public_key, err, response, body, cb);
                    }
                });
            }
            
            if ( config.edge_config.redisBasedConfigCache === true ) { //retrieve info from redis db
                getConfigFromRedis(redisClient, globalOptions, config.edge_config.jwt_public_key, 'jwt_public_key', function(err, body){
                    const response =  err ? null : { statusCode: 200, statusMessage: 'Downloaded from redis' };
                    _loadStatus('jwt_public_key', config.edgemicro.redisHost, err, response, body, cb);
                });
            } 
        },

Reference:
https://github.com/apigee/microgateway-config/blob/v3.1.5/lib/network.js#L377

However, the same is not done for jwk_public_keys:

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);
                }
            });
        }

Reference:
https://github.com/apigee/microgateway-config/blob/v3.1.5/lib/network.js#L406