Я реализовал сервер аутентификации, построенный на основе Spring-Boot, oauth2 с нижними конечными точками:
- / oauth / token
- / oauth / check_token
- / oauth / token_key
Я пытаюсь интегрировать этот сервер аутентификации в один из моих серверов реактивных ресурсов. Попробовал ниже config:
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) throws Exception {
http
.authorizeExchange()
.pathMatchers("/**").hasAuthority("role_admin")
.anyExchange().authenticated()
.and()
.oauth2ResourceServer()
.jwt();
return 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"
Согласно В результате моего исследования я обнаружил, что файл-эмитента-api является конечной точкой конфигурации серверов авторизации (в соответствии со стандартами OID C). Если да, то как мне выставить то же самое на моем сервере аутентификации?
Я искал в Интернете, но в большинстве примеров используются сторонние поставщики аутентификации, такие как Okta.
Заранее спасибо.