简体   繁体   中英

Typesafe config secure rendeing

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())

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM