quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.83k stars 2.7k forks source link

Change the JsonRPC Service for OIDC to use recorder #44590

Open phillip-kruger opened 2 days ago

phillip-kruger commented 2 days ago

This is for #44181. It does not fix it, but takes Dev UI out of the picture.

This PR change the way we make data available to the JSON RPC service. It now use a recorder to record it directly on the JsonRPC Service.

On another note, we can probably use build time data (that can also accept a runtime value) for some of the json-rpc methods. However this is a bigger and riskier change (with the same result) so I kept it simple. If the maintainers (@sberyozkin) wants to pursue this I can show what I suggest.

quarkus-bot[bot] commented 2 days ago

:waning_crescent_moon: This workflow status is outdated as a new workflow run has been triggered.

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 8c038b15c320601c1ef929adefe01f40de803af5.

Failing Jobs

Status Name Step Failures Logs Raw logs Build scan
JVM Tests - JDK 17 Build Failures Logs Raw logs :mag:
JVM Tests - JDK 21 Build Failures Logs Raw logs :mag:

Full information is available in the Build summary check run. You can consult the Develocity build scans.

Failures

:gear: JVM Tests - JDK 17 #

- Failing: extensions/oidc/deployment 
! Skipped: extensions/keycloak-authorization/deployment extensions/oidc-client-filter/deployment extensions/oidc-client-graphql/deployment and 21 more

:package: extensions/oidc/deployment

io.quarkus.oidc.test.CodeFlowDevModeDefaultTenantTestCase.testAccessAndRefreshTokenInjectionDevMode - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.CodeFlowDevModeTestCase.testAccessAndRefreshTokenInjectionDevMode line 102 - History - More details - Source on GitHub

``` org.opentest4j.AssertionFailedError: expected: <401> but was: <500> at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151) at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132) at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197) at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150) at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:145) at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:531) at io.quarkus.oidc.test.CodeFlowDevModeTestCase.testAccessAndRefreshTokenInjectionDevMode(CodeFlowDevModeTestCase.java:102) ```

io.quarkus.oidc.test.CodeFlowDevModeTestCase.testAccessTokenVerified line 147 - History - More details - Source on GitHub

``` org.htmlunit.FailingHttpStatusCodeException: 500 Internal Server Error for http://localhost:8080/protected/access-token-name at org.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:749) at org.htmlunit.WebClient.getPage(WebClient.java:503) at org.htmlunit.WebClient.getPage(WebClient.java:402) at org.htmlunit.WebClient.getPage(WebClient.java:538) at org.htmlunit.WebClient.getPage(WebClient.java:520) at io.quarkus.oidc.test.CodeFlowDevModeTestCase.testAccessTokenVerified(CodeFlowDevModeTestCase.java:147) at java.base/java.lang.reflect.Method.invoke(Method.java:569) ```

io.quarkus.oidc.test.CodeFlowManagementInterfaceDevModeTest.testAuthenticatedHttpPermission - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.CustomIdentityProviderTestCase.testCustomIdentityProviderFailure - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.CustomIdentityProviderTestCase.testCustomIdentityProviderSuccess - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.ImplicitBasicAuthAndBearerAuthCombinationTest.testBasicEnabledAsSelectedWithAnnotation - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.ImplicitBasicAuthAndCodeFlowAuthCombinationTest.testBasicEnabledAsSelectedWithHttpPerm - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

:gear: JVM Tests - JDK 21 #

- Failing: extensions/oidc/deployment 
! Skipped: extensions/keycloak-authorization/deployment extensions/oidc-client-filter/deployment extensions/oidc-client-graphql/deployment and 21 more

:package: extensions/oidc/deployment

io.quarkus.oidc.test.CodeFlowDevModeDefaultTenantTestCase.testAccessAndRefreshTokenInjectionDevMode - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.CodeFlowDevModeTestCase.testAccessAndRefreshTokenInjectionDevMode line 102 - History - More details - Source on GitHub

``` org.opentest4j.AssertionFailedError: expected: <401> but was: <500> at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151) at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132) at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197) at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150) at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:145) at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:531) at io.quarkus.oidc.test.CodeFlowDevModeTestCase.testAccessAndRefreshTokenInjectionDevMode(CodeFlowDevModeTestCase.java:102) ```

io.quarkus.oidc.test.CodeFlowDevModeTestCase.testAccessTokenVerified line 147 - History - More details - Source on GitHub

``` org.htmlunit.FailingHttpStatusCodeException: 500 Internal Server Error for http://localhost:8080/protected/access-token-name at org.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:749) at org.htmlunit.WebClient.getPage(WebClient.java:503) at org.htmlunit.WebClient.getPage(WebClient.java:402) at org.htmlunit.WebClient.getPage(WebClient.java:538) at org.htmlunit.WebClient.getPage(WebClient.java:520) at io.quarkus.oidc.test.CodeFlowDevModeTestCase.testAccessTokenVerified(CodeFlowDevModeTestCase.java:147) at java.base/java.lang.reflect.Method.invoke(Method.java:580) ```

io.quarkus.oidc.test.CodeFlowManagementInterfaceDevModeTest.testAuthenticatedHttpPermission - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.CustomIdentityProviderTestCase.testCustomIdentityProviderFailure - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.CustomIdentityProviderTestCase.testCustomIdentityProviderSuccess - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.ImplicitBasicAuthAndBearerAuthCombinationTest.testBasicEnabledAsSelectedWithAnnotation - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```

io.quarkus.oidc.test.ImplicitBasicAuthAndCodeFlowAuthCombinationTest.testBasicEnabledAsSelectedWithHttpPerm - History - More details - Source on GitHub

``` java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor#prepareOidcDevConsole threw an exception: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Vertx.createHttpClient(io.vertx.core.http.HttpClientOptions)" because "vertx" is null at io.vertx.ext.web.client.WebClient.create(WebClient.java:72) at io.vertx.mutiny.ext.web.client.WebClient.create(WebClient.java:164) at io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.createWebClient(OidcDevServicesUtils.java:33) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.discoverMetadata(OidcDevUIProcessor.java:148) at io.quarkus.oidc.deployment.devservices.OidcDevUIProcessor.prepareOidcDevConsole(OidcDevUIProcessor.java:80) ```
quarkus-bot[bot] commented 2 days ago

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 0d98259214c8c874447e160f945dc955e5c8de74.

:white_check_mark: The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.


Flaky tests - Develocity

:gear: JVM Tests - JDK 17

:package: integration-tests/oidc-code-flow

io.quarkus.it.keycloak.CodeFlowTest.testTokenRefresh - History

``` org.opentest4j.AssertionFailedError: expected: but was: at io.quarkus.it.keycloak.CodeFlowTest$3.call(CodeFlowTest.java:733) at io.quarkus.it.keycloak.CodeFlowTest$3.call(CodeFlowTest.java:720) at org.awaitility.core.CallableCondition$ConditionEvaluationWrapper.eval(CallableCondition.java:99) at org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:248) at org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:235) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ```
michalvavrik commented 1 day ago

On another note, we can probably use build time data (that can also accept a runtime value) for some of the json-rpc methods. However this is a bigger and riskier change (with the same result) so I kept it simple. If the maintainers (@sberyozkin) wants to pursue this I can show what I suggest.

I am interested.

sberyozkin commented 1 day ago

Thanks @phillip-kruger @michalvavrik, I'll quickly try this PR with both Keycloak and non Keycloak provider, soon and merge then

phillip-kruger commented 1 day ago

On another note, we can probably use build time data (that can also accept a runtime value) for some of the json-rpc methods. However this is a bigger and riskier change (with the same result) so I kept it simple. If the maintainers (@sberyozkin) wants to pursue this I can show what I suggest.

I am interested.

@michalvavrik - So for the getProperties method, that can move to a BuildTimeAction. This means that you do not need to create a JsonRPC method, you just provide the code in the deployment module. See https://quarkus.io/guides/dev-ui#jsonrpc-against-the-deployment-classpath

The BuildTimeAction can also take a RuntimeValue that will be returned, meaning you can record the data in the recoreder, and that will be returned on the getProperties call.