Typesafe配置安全渲染

时间:2016-07-04 16:10:01

标签: configuration typesafe typesafe-stack

我有以下代码

log(config.render())

但是如果我在配置中有密码,那么它们就会出现在日志中。是否有简单方法来消除这种情况?我正在寻找类似的东西

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

1 个答案:

答案 0 :(得分:0)

目前唯一明确的解决办法就是这样做

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

明显的缺点是它只隐藏了确切的配置子树