当在 pom.xml 中使用简单的 spring boot 配置和正常的 spring 父级时,我在配置 oauth2 资源服务器时没有问题。
但是,使用 JHipster 依赖管理我绝对无法配置它。 我试图通过添加来做到这一点
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<version>[spring version]</version>
</dependency>
或者通过使用一些旧的配置和其他依赖项,如下所示:https://docs.spring.io/spring-security-oauth2-boot/docs/2.2.x-SNAPSHOT/reference/html/boot-features-security-oauth2-resource-server.html
通常它可以工作,但是使用 JHipster 我得到了 @EnableResourceServer 注释,但在 IntelliJ spring.security.oauth2.resourceserver
属性中没有。因此,我无法配置应由哪个服务器验证 token ,并且 HttpSecurity http (WebSecurityConfigurerAdapter) 中没有 .oauth2ResourceServer()
方法。我不明白为什么会发生这种情况。我怎样才能获得这些属性?或者也许我可以通过自定义配置以某种方式覆盖它?
最佳答案
JHipster默认配置为资源服务器,因此您不需要添加任何额外的配置。
来自SecurityConfiguration.java :
.oauth2ResourceServer()
.jwt()
.jwtAuthenticationConverter(authenticationConverter())
.and()
.and()
.oauth2Client();
关于spring - JHipster - Spring 。 Oauth2 资源服务器配置。创建资源服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71217972/