Spring boot 反应式spring安全中的OAuth2-无法使用提供的颁发者解决配置问题
我已经实现了一个基于spring boot构建的auth服务器,oauth2具有以下端点:Spring boot 反应式spring安全中的OAuth2-无法使用提供的颁发者解决配置问题,spring-boot,spring-security,oauth-2.0,reactive,Spring Boot,Spring Security,Oauth 2.0,Reactive,我已经实现了一个基于spring boot构建的auth服务器,oauth2具有以下端点: /oauth/令牌 /oauth/check_令牌 /oauth/令牌密钥 我正在尝试将此身份验证服务器集成到我的一个反应式资源服务器中。 在以下配置中尝试: spring: security: oauth2: resourceserver: jwt: issuer-uri: http://localhost:9001/oauth/token
spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: http://localhost:9001/oauth/token
client:
provider:
custom-provider:
issuer-uri: http://localhost:9001/oauth/token
token-uri: http://localhost:9001/oauth/token
authorization-uri: http://localhost:9001/auth/oauth/authorize
user-info-uri: http://localhost:9001/auth/user/me
user-name-attribute: name
registration:
custom-client:
client-id: USER_CLIENT_APP
client-secret: password
client-name: Auth Server
# scope: user_info
provider: custom-provider
# redirect-uri-template: http://localhost:8082/login/oauth2/code/
client-authentication-method: basic
authorization-grant-type: password
在SecurityConfig下面
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http)引发异常{
http
.授权交易所()
.pathMatchers(“/**”).hasAuthority(“角色管理”)
.anyExchange().authenticated()
.及()
.oauth2ResourceServer()
.jwt();
返回http.build();
}
生成文件:
plugins {
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.turtlemint'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "Hoxton.RELEASE")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
compile group: 'org.springframework.boot', name: 'spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
implementation 'org.springframework.cloud:spring-cloud-starter-zipkin'
compile group: 'com.google.guava', name: 'guava', version: '28.1-jre'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
//implementation 'org.springframework.cloud:spring-cloud-starter-security'
compile 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testCompile group: 'io.projectreactor', name: 'reactor-test', version: '3.1.0.RELEASE'
testCompile group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.2.4'
compile group: 'org.junit', name: 'junit5-engine', version: '5.0.0-ALPHA'
compile group: 'org.springframework.security', name: 'spring-security-oauth2-resource-server', version: '5.2.2.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-oauth2-jose', version: '5.2.2.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-config', version: '5.2.2.RELEASE'
//compile group: 'org.springframework.security', name: 'spring-security-oauth2-client', version: '5.2.2.RELEASE'
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtDecoderByIssuerUri' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerJwkConfiguration$JwtConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.jwt.ReactiveJwtDecoder]: Factory method 'jwtDecoderByIssuerUri' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve the Configuration with the provided Issuer of "http://localhost:9001/oauth/token"
根据我的研究,我发现issuer api是身份验证服务器配置端点(根据OIDC标准)。如果是,如何在身份验证服务器中公开相同的内容
我在网上搜索过,但大多数示例都使用第三方身份验证提供商,如Okta
提前感谢。您可以参考与spring security相关的springboot示例应用程序,可能会对您有所帮助。我也遇到了同样的问题。任何帮助都将不胜感激