Masking request_uri in analytics for microgateway

Not applicable

Hi,

We want to mask request_uri, request_path and proxy_pathsuffix when it gets logged into analytics.

After looking at https://github.com/apigee-127/volos/blob/master/analytics/apigee/lib/apigeeanalytics.js, we had gone ahead and set the value of req.url to *** in a plugin as follows -

module.exports.init = function(config, logger, stats) {
  return {
    onend_response: function(req, res, data, next) {
      req.url = '*****';
      // oauth
      if (req.token) {
        req.token.access_token = '*****';
      }
      next(null, null);
    }
  };
}

But, the data is not being masked when we query analytics.

We are currently trying with 2.3.3-beta of edgemicro.

P.S: This is continuation of discussion at https://github.com/apigee/microgateway-plugins/pull/6. Since that has been closed.

Thanks,

Jaskaran

0 9 132
9 REPLIES 9

Jaskaran,

I believe once you hit the onend_response event the record has already counted itself as finalized, and will try and send unmasked info.

Have you tried setting that mask in the onresponse handler instead?

-Matt

Tried just now. But with same result 😞

By the way, in my example above the access token is being masked. But not request uri and path.

Looking through the code, and how the analytics plugin is placed first before other plugins it may be hard to accomplish this masking without a pull request and configuration addition to the analytics plugin itself.

Oops. So, are the request fields set before and the access token later. I was just wondering how, access_token is being masked but not request fields.

Ok. just looked at the source, accesstoken is being set in onFinished.

Ah. I didn't see the token was being masked but not req.url.

another candidate for a hook is onend_request.

If that doesn't work properly then we need to investigate what a config for masking in the plugin would look like.

The analytics plugin runs before all others. So intercepting request info and altering may be difficult.

Let me know if you are still having issues trying to mask things. It seems like this may need to be a config option on EM.