Spring Cloud Config Server 返回额外的反斜杠
我正在 Vault 中编写一个类似于 secret1=test1\ntest2
的机密,并使用 @Value("${secret1}")
在 Spring Boot 应用程序配置中使用它。但是,通过 Spring Cloud Config Server 从 Vault 成功检索后,secret1
值将转换为 test1**\\n**test1
。因此添加了一个额外的反斜杠。这是我需要在应用程序中进行的一个非常小的更改,以删除多余的反斜杠,但我想以正确的方式解决这个问题。如何防止这种额外的反斜杠添加发生?
I'm writing a secret in Vault similar to secret1=test1\ntest2
and use it inside a Spring Boot application configuration using @Value("${secret1}")
. However, upon successful retrieval from Vault via Spring Cloud Config Server the secret1
value is turned into test1**\\n**test1
. So an extra backslash is added. It is a very small change that I would need to do in the application to remove that extra backslash, but I'd like to solve this the proper way. How can I prevent this extra backslash addition from happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Vault 本身不会干扰
\n
。在命令行尝试此操作:在线路上,它将作为以下 JSON 发送:
获取秘密会带来相同的值:
您的
\n
可能会被解释为以 JSON 格式转换并发送到避难所。也许将秘密放入 Vault 的任何内容都不会使用与您的代码相同的库/技术?确保在将
\n
保存到保险柜时对其进行转义。得到它将使\n
毫发无伤地回来。Vault itself will not mess with the
\n
. Try this at the command line:On the wire, it will be sent as this JSON:
And getting the secret back brings the same value:
Your
\n
is probably interpreted as it is transformed in JSON and sent to Vault. Maybe whatever puts the secret in Vault does not use the same library/technology as your code?Make sure that you escape the
\n
when it is saved in Vault. Getting it will bring back the\n
unharmed.