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

Obfuscate JSON Request Body #226

Closed
IkoroVictor opened this issue Apr 27, 2018 · 1 comment
Closed

Obfuscate JSON Request Body #226

IkoroVictor opened this issue Apr 27, 2018 · 1 comment

Comments

@IkoroVictor
Copy link

IkoroVictor commented Apr 27, 2018

I'm using the logbook-spring-boot-starter 1.7.0, and currently "access_token" in the JSON response 'body' is obfuscated, which is fine. But when I try to obfuscate other fields by setting them in logbook.obfuscate.parameters property, nothing happens. Is the logbook.obfuscate.parameters only limited to 'query' parameters and not request/response 'body'. Also if that's the case, how do I set fields to obfuscate from a JSON body.

Looking through the configuration class, it seems one needs to create a BodyFilter bean using the BodyFilters.replaceJsonStringProperty, passing the fields required to be masked.

The regex pattern in BodyFilters.replaceJsonStringProperty doesn't seem to cater for fields with array values.

@whiskeysierra
Copy link
Collaborator

whiskeysierra commented Apr 28, 2018

Is the logbook.obfuscate.parameters only limited to 'query' parameters and not request/response 'body'

Indeed.

List of parameter names that need obfuscation

https://github.com/zalando/logbook#configuration:

What you're looking for is the BodyFilter interface. See https://github.com/zalando/logbook#filtering. Any implementation of that interface will be picked up by the spring boot integration via Spring's application context.

For string properties you may use BodyFilters.replaceJsonStringProperty. Anything more sophisticated than that would require a custom implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants