Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OIDC client: quarkus.oidc-client.enabled does not working in combinatie with @RegisterProvider(OidcClientRequestReactiveFilter.class). #41827

Closed
argenstijn opened this issue Jul 11, 2024 · 2 comments · Fixed by #43374
Labels
area/oidc env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@argenstijn
Copy link

Describe the bug

While testing you can disabled the oidc client by setting quarkus.oidc-client.enabled to false. This work perfectly in combination with @OidcClientFilter. But not when you are using @RegisterProvider using the default class or custom class.

Expected behavior

oidc Client is disabled when using @RegisterProvider

Actual behavior

Caused by: java.lang.NullPointerException: Cannot invoke "io.quarkus.oidc.client.OidcClients.getClient()" because "oidcClients" is null
	at io.quarkus.oidc.client.runtime.AbstractTokensProducer.init(AbstractTokensProducer.java:43)
	at io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter_Bean.doCreate(Unknown Source)
	at io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter_Bean.create(Unknown Source)
	at io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter_Bean.get(Unknown Source)
	at io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter_Bean.get(Unknown Source)
	at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:559)
	at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:539)
	at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:572)
	at io.quarkus.arc.impl.ArcContainerImpl.instanceHandle(ArcContainerImpl.java:534)
	at io.quarkus.arc.impl.ArcContainerImpl.instance(ArcContainerImpl.java:294)
	at io.quarkus.rest.client.reactive.runtime.RestClientBuilderImpl.register(RestClientBuilderImpl.java:292)
	at io.quarkus.rest.client.reactive.runtime.RestClientBuilderImpl.build(RestClientBuilderImpl.java:408)
	at io.quarkus.rest.client.reactive.runtime.QuarkusRestClientBuilderImpl.build(QuarkusRestClientBuilderImpl.java:267)
	at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.build(RestClientCDIDelegateBuilder.java:67)
	at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.createDelegate(RestClientCDIDelegateBuilder.java:49)
	at io.quarkus.rest.client.reactive.runtime.RestClientReactiveCDIWrapperBase.delegate(RestClientReactiveCDIWrapperBase.java:76)
	at io.quarkus.rest.client.reactive.runtime.RestClientReactiveCDIWrapperBase.<init>(RestClientReactiveCDIWrapperBase.java:30)

How to Reproduce?

  1. create oidc client and disabled it
  2. activate the client by using the annotation @RegisterProvider

Output of uname -a or ver

Microsoft Windows [Version 10.0.19045.4529]

Output of java -version

openjdk 21.0.2 2024-01-16 LTS OpenJDK Runtime Environment Corretto-21.0.2.13.1 (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Corretto-21.0.2.13.1 (build 21.0.2+13-LTS, mixed mode, sharing)

Quarkus version or git rev

3.12.2

Build tool (ie. output of mvnw --version or gradlew --version)

3.9.6

Additional information

No response

@argenstijn argenstijn added the kind/bug Something isn't working label Jul 11, 2024
@quarkus-bot quarkus-bot bot added area/oidc env/windows Impacts Windows machines labels Jul 11, 2024
Copy link

quarkus-bot bot commented Jul 11, 2024

/cc @pedroigor (oidc), @sberyozkin (oidc)

@sberyozkin
Copy link
Member

sberyozkin commented Jul 11, 2024

@argenstijn

When you use @RegisterProvider it is done at the REST client level to which OidcClientRequestReactiveFilter.class means only that it is just some provider class, it does not know anything about OIDC client or if the feature is disabled.

@OidcClient is managed directly at the OIDC client build steps level which is only activated if the OIDC client feature is enabled.

We can probably add a check at the filter level to avoid NPEs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/oidc env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants