阻止:spring引导升级后出现混合内容错误
我已经将一些相互通信的微服务从Spring Boot 1.5.3升级到2.3.5。 现在,当我的微服务A呼叫微服务B时,呼叫失败,状态如下 在chrome开发者工具的网络标签上(阻止:混合内容) 我不确定是什么改变了我开始出现这个错误 在浏览器的控制台中,我得到以下错误:阻止:spring引导升级后出现混合内容错误,spring,spring-boot,spring-security,spring-boot-2,Spring,Spring Boot,Spring Security,Spring Boot 2,我已经将一些相互通信的微服务从Spring Boot 1.5.3升级到2.3.5。 现在,当我的微服务A呼叫微服务B时,呼叫失败,状态如下 在chrome开发者工具的网络标签上(阻止:混合内容) 我不确定是什么改变了我开始出现这个错误 在浏览器的控制台中,我得到以下错误: Mixed Content: The page at 'https://gateway-url/my-endpoint' was loaded over HTTPS, but requested an insecure XML
Mixed Content: The page at 'https://gateway-url/my-endpoint' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://micro-service-b-url/login'. This request has been blocked; the content must be served over HTTPS.
奇怪的是,在我的整个代码库中没有端点/login。
我无法理解springboot升级后的这种行为
请提供有关spring引导升级如何导致此错误以及可能的解决方案的任何指导
注意:我发现一些答案建议使用下面的代码来解决这个问题
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
但它似乎不适用于所有浏览器,我不确定从安全性角度来看使用此解决方案是否安全。了解问题并找到了解决方案 看起来SpringBoot 1中使用的安全挂钩在SpringBoot 2中已被弃用。 因此,在我的微服务B中,属性文件中的以下配置在升级后不起作用
security.basic.enable: false
security.ignored=/**
结果,SpringBoot 2在微服务B上强制执行默认安全配置,通过网关对微服务B的调用被重定向到web sso登录,从而导致调用神秘的/login端点
解决方案是禁用默认安全性。我执行了以下步骤:
1. Removed deprecated hooks from properties file:
security.basic.enable: false
security.ignored=/**
2. Disabled default security using below config
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class,
ManagementWebSecurityAutoConfiguration.class })
public class MyApplication extends WebMvcConfigurerAdapter{
注意:我必须排除ManagementWebSecurityAutoConfiguration.class,因为micro服务使用的是SpringBoot执行器