【问题标题】:Using Spring Cloud Config not getting encrypted value?使用 Spring Cloud Config 未获得加密值?
【发布时间】:2018-10-21 08:06:29
【问题描述】:

我正在尝试使用 Spring Cloud Config Server 对配置值进行加密/解密。

为此,在 Config Server 项目下进行了以下更改:

在bootstrap.properties

中
encrypt.key=abcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh

我还在我的 Ubuntu 18.04 机器上使用以下命令更新了 JCE:

sudo apt install oracle-java8-unlimited-jce-policy

但是在发出 POST 请求后,我看不到任何响应。

理想情况下,请求正文的加密文本应该作为响应。

示例项目:https://github.com/Omkar-Shetkar/pluralsight-springcloud-m2-git

这里可能缺少什么?

谢谢。

【问题讨论】:

    标签: spring-cloud spring-cloud-config


    【解决方案1】:

    实际上是由于 CSRF,得到 401-unauthorized response。从 Spring Boot 2.0 开始,我们可以在代码中禁用它。

    这里有详细的答案: spring config server encrypt forbidden

    按照上述步骤解决了问题。

    【讨论】:

      【解决方案2】:

      只是放在那里,如果有人坚持我的愚蠢错误,即使做了以上所有事情,如果 /encrypt 端点仍然没有被授权。

      请检查您的安全适配器类。如果你也覆盖了下面的方法

        @Autowired
        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
          auth.inMemoryAuthentication()
              .withUser("user")
              .password(passwordEncoder().encode(userPassword))
              .roles("USER")
              .and()
              .withUser("admin")
              .password(passwordEncoder().encode(adminPassword))
              .roles("USER", "ADMIN");
        }
      

      您需要在授权选项卡的基本身份验证选项下提供这些凭据

      【讨论】:

        猜你喜欢
        • 2016-09-26
        • 2020-09-05
        • 1970-01-01
        • 1970-01-01
        • 2017-01-27
        • 2021-10-07
        • 1970-01-01
        • 1970-01-01
        • 2016-06-26
        相关资源
        最近更新 更多