在 Spring Boot 1 和 2 中引入 Spring Security 并配置了 web.ignoreUrls,这个配置会被 Spring Boot 1 中引入的 Spring Security 覆盖,导致失效。\n\n在 Spring Boot 1 中,Spring Security 默认会启用,并且会应用默认的安全配置,包括拦截所有的 URL。因此,即使你在配置文件中配置了 web.ignoreUrls,也会被 Spring Security 覆盖掉。\n\n而在 Spring Boot 2 中,Spring Security 的默认行为有所改变。Spring Boot 2 引入了一个新的 auto-configuration 模块,该模块会根据配置文件中的 spring.security.* 属性来自动配置 Spring Security。如果你在配置文件中配置了 web.ignoreUrls,它会生效并覆盖掉 Spring Security 的默认配置。\n\n所以,如果你想在 Spring Boot 1 中使用 web.ignoreUrls 来配置忽略的 URL,你需要手动配置 Spring Security 来覆盖默认的安全配置。而在 Spring Boot 2 中,你可以直接使用 web.ignoreUrls 来配置忽略的 URL,不需要额外的配置。


原文地址: http://www.cveoy.top/t/topic/pSFm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录