I am trying to use obfuscate mechanism from zalando logbook
Previously i had my own Configuration for this
@Configuration
@EnableConfigurationProperties(LogbookObfuscateJsonBodyProperties.class)
public class LogbookObfuscateJsonBodyConfig {
@Bean
public BodyFilter sensitiveDataBodyFilter(LogbookObfuscateJsonBodyProperties properties) {
if (properties.toObfuscate() == null) {
return BodyFilter.none();
}
return properties.toObfuscate().stream()
.map(path -> JsonPathBodyFilters.jsonPath(path).replace("XXX"))
.reduce(BodyFilter::tryMerge)
.orElse(BodyFilter.none());
}
}
@ConfigurationProperties(prefix = "app.logbook.json.body")
public record LogbookObfuscateJsonBodyProperties(List<String> toObfuscate) {
}
and i was obfuscating fields in my application.yml files like that
app:
logbook:
json:
body:
to_obfuscate:
- .fieldToObfuscate
Right now i wanted to use logbook build in obfuscation so i removed my Configuration and tried with this approach in my application.yml file
logbook:
obfuscate:
json-body-fields:
- .fieldToObfuscate
But it looks like it is not working as i still see fields not obfuscated. Any ideas what might be wrong ?
@Update heres BodyFilter which i used before:
@Bean
public BodyFilter defaultBodyFilter(LogbookProperties properties) {
final LogbookProperties.Write write = properties.getWrite();
final int maxBodySize = write.getMaxBodySize();
if (maxBodySize < 0) {
return defaultValue();
}
return BodyFilter.merge(defaultValue(), truncate(maxBodySize));
}