使用 @enableresourceserver 从 Spring 5.x 迁移到 6.x

问题描述 投票:0回答:1

我正在尝试将 spring 5.x 迁移到 6.x,但找不到 websecurityconfigadaptor。我知道它已被弃用,但我没有直接使用它,但我相信它是间接从 @enableresourceserver 获取的。如何避免这种依赖关系被隐藏或完全从@enableresourceserver 迁移到resourceserverconfig 实现resourceserverconfigadaptor。 这适用于 REST API,其中 JWT 令牌用于授权。 任何输入都会有帮助

我尝试了不同的 jar 版本组合,并尝试删除 @enableresourceserver 注释,但没有成功。 我确实在6.x和springboot 3中找到了与@enableresourceserver相关的任何信息

java spring-security migration java-17 spring-boot-3
1个回答
0
投票

只需添加 spring-boot-starter-oauth2-resource-server dependentecny 并配置一个属性: spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:config/public.txt

public.txt中的内容是解析jwttoken的公钥

 <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
 </dependency>
© www.soinside.com 2019 - 2024. All rights reserved.