Search code examples
clojurering

Filter sensitive parameters from logs in clojure ring app


I'm using wrap-with-logger (from ring.middleware.logger) and wrap-params (from ring.middleware.params) middlewares in my application. Any simple way to filter sensitive parameters (password, credit card number etc.) from logs?


Solution

  • You could also consider migrating to ring-logger which includes a feature to redact sensitive information:

    By default, ring-logger will redact an authorization header or any param named password (at any nesting level). If you want ring-logger to redact other params you can configure the redact-keys option:

       (wrap-with-logger app {:redact-keys #{:senha :token})
    

    Ring-logger will walk through the params and headers and redact any key whose name is found in that redact-keys set.

    There's also ring-logger-onelog that should make it very easy to migrate from ring.middleware.logger to ring-logger