My logging is set up to log $request_body
out to syslog, but it's including sensitive data in the logs.
For example, the password is coming through on the logs as \x22password\x22
when the user logs in. For the time being, I want to persist the surrounding data and obfuscate the password only.
For example, when a user logs in and POSTs to the authentication backend, it's logged as
body: "{\x22username\x22:\x22myname@mydomain.com\x22,\x22password\x22:\x22One2Three4!?\x22}"
but I want it to be logged instead as
body: "{\x22username\x22:\x22myname@mydomain.com\x22,\x22password\x22:\x22********\x22}"
I've seen there's an ability to map out fields in typical query string parameter formatting, but I'm not particularly skilled at regex.
I've looked here NGINX: Obfuscate password in access_log but the question isn't answered. Hoping to get some regex guidance on this one, regardless of best practices and security concerns.
How can I obfuscate the password in the logging with this format of response body?