diff --git a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/jwt/NoopReactiveJwtDecoder.java b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/jwt/NoopReactiveJwtDecoder.java new file mode 100644 index 00000000000..364175c026d --- /dev/null +++ b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/jwt/NoopReactiveJwtDecoder.java @@ -0,0 +1,15 @@ +package no.nav.testnav.libs.reactivesecurity.jwt; + +import org.springframework.security.oauth2.jwt.Jwt; +import org.springframework.security.oauth2.jwt.JwtException; +import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder; +import reactor.core.publisher.Mono; + +class NoopReactiveJwtDecoder implements ReactiveJwtDecoder { + + @Override + public Mono decode(String token) throws JwtException { + return Mono.just(Jwt.withTokenValue(null).build()); + } + +} diff --git a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/jwt/ReactiveJwtAutoConfiguration.java b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/jwt/ReactiveJwtAutoConfiguration.java new file mode 100644 index 00000000000..1ab12506072 --- /dev/null +++ b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/jwt/ReactiveJwtAutoConfiguration.java @@ -0,0 +1,21 @@ +package no.nav.testnav.libs.reactivesecurity.jwt; + +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder; + +@AutoConfiguration +public class ReactiveJwtAutoConfiguration { + + @Primary + @Bean + @Profile("test") + @ConditionalOnBean(ReactiveJwtDecoder.class) + ReactiveJwtDecoder reactiveJwtDecoderForTesting() { + return new NoopReactiveJwtDecoder(); + } + +} diff --git a/libs/reactive-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/libs/reactive-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 618cfd98c75..19107bc880b 100644 --- a/libs/reactive-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/libs/reactive-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1,2 @@ -no.nav.testnav.libs.reactivesecurity.exchange.TokenServiceAutoConfiguration \ No newline at end of file +no.nav.testnav.libs.reactivesecurity.exchange.TokenServiceAutoConfiguration +no.nav.testnav.libs.reactivesecurity.jwt.ReactiveJwtAutoConfiguration \ No newline at end of file