升级到 Boot 3.2.0后,我的Spring Authorization Server不再工作了,在尝试使用Authorization Code流进行身份验证时显示No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken
错误:
的数据
我使用Spring Authorization Server "Getting Started" docs上显示的最小配置。
1条答案
按热度按时间u4dcyp6a1#
Boot 3.2发行说明中解释了此行为更改:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#auto-configured-user-details-service
自动配置的
InMemoryUserDetailsManager
现在在[...]spring-security-oauth2-resource-server
[...]在类路径上时会回退。[...]如果您使用上述依赖项之一,但仍然需要
InMemoryUserDetailsManager
[...],请在应用程序中定义所需的bean。spring-security-oauth2-authorization-server
将Spring Security Resource Server库作为其依赖项之一,因此表单登录失败。所以,我现在已经在Sping Boot 项目中创建了一个问题来指出这一点并确认这是预期的行为,否则,如果他们打算改变Spring AS最小设置的行为:
https://github.com/spring-projects/spring-boot/issues/38864
Spring Authorization Server项目也报告了此问题:
https://github.com/spring-projects/spring-authorization-server/issues/1475的
最后,在定义之前的一个临时解决方案是按照发行说明中的建议声明一个
InMemoryUserDetailsManager
bean。例如,如果我们想使用我们定义的
spring.security.user.name
和spring.security.user.password
应用程序属性复制 Boot 自动配置,我们可以声明以下bean:字符串