Typesafe config secure rendeing

157 Views Asked by At

I have the following code

log(config.render())

However if I have passwords in the config then they'll appear in log. Is there easy way to eliminate this? I am looking for something like that

log(config.map { if ("password" in it.key.toLowerCase()) "***" else it.value }
    .render())
1

There are 1 best solutions below

0
Sergey Mashkov On

For now the only clear solution is to do like this

val contentHiddenValue = ConfigValueFactory.fromAnyRef("***", "Content hidden")
log.info(config.root()
        .withoutKey("security")
        .withValue("security", contentHiddenValue)
        .render())

The obvious disadvantage is that it hides only exact config subtree