I have implemented an auth-server built on spring-boot, oauth2 with below end-points:
- /oauth/token
- /oauth/check_token
- /oauth/token_key
I am trying to integrate this auth-server in one of my reactive resource server. Tried below 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
And below SecurityConfig
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception {
http
.authorizeExchange()
.pathMatchers("/**").hasAuthority("role_admin")
.anyExchange().authenticated()
.and()
.oauth2ResourceServer()
.jwt();
return http.build();
}
Build file:
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()
}
Error:
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"
As per my research, what I found was that the issuer-api is the auth-servers config end-point (as per OIDC standards). If so, how do I expose the same in my auth-server?
I searched online, but most of the examples are using third party auth providers like Okta.
Thanks in advance.