From da14960c8659576b7d49d4d0788a50ac03cfb762 Mon Sep 17 00:00:00 2001 From: Sergey Beryozkin Date: Sun, 14 Nov 2021 16:18:22 +0000 Subject: [PATCH] Support extra params for OidcClient password grant --- .../io/quarkus/oidc/client/runtime/OidcClientRecorder.java | 6 ++++++ .../src/main/resources/application.properties | 1 + .../quarkus/it/keycloak/KeycloakRealmResourceManager.java | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java b/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java index 70a586ce339cd..0060428bfd970 100644 --- a/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java +++ b/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java @@ -159,6 +159,12 @@ public OidcClient apply(String tokenRequestUri, Throwable t) { grantOptions.get(OidcConstants.PASSWORD_GRANT_USERNAME)); tokenGrantParams.add(OidcConstants.PASSWORD_GRANT_PASSWORD, grantOptions.get(OidcConstants.PASSWORD_GRANT_PASSWORD)); + for (Map.Entry entry : grantOptions.entrySet()) { + if (!OidcConstants.PASSWORD_GRANT_USERNAME.equals(entry.getKey()) + && !OidcConstants.PASSWORD_GRANT_PASSWORD.equals(entry.getKey())) { + tokenGrantParams.add(entry.getKey(), entry.getValue()); + } + } } else { tokenGrantParams.addAll(grantOptions); } diff --git a/integration-tests/oidc-client-wiremock/src/main/resources/application.properties b/integration-tests/oidc-client-wiremock/src/main/resources/application.properties index d7f48a4442734..6da18c060ec5f 100644 --- a/integration-tests/oidc-client-wiremock/src/main/resources/application.properties +++ b/integration-tests/oidc-client-wiremock/src/main/resources/application.properties @@ -18,6 +18,7 @@ quarkus.oidc-client.non-standard-response.grant.refresh-token-property=refreshTo quarkus.oidc-client.non-standard-response.grant.expires-in-property=expiresIn quarkus.oidc-client.non-standard-response.grant-options.password.username=alice quarkus.oidc-client.non-standard-response.grant-options.password.password=alice +quarkus.oidc-client.non-standard-response.grant-options.password.extra_param=extra_param_value quarkus.oidc-client.non-standard-response.headers.X-Custom=XCustomHeaderValue quarkus.oidc-client.non-standard-response-without-header.auth-server-url=${keycloak.url} diff --git a/integration-tests/oidc-client-wiremock/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java b/integration-tests/oidc-client-wiremock/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java index 93a509926d7e5..a2ca7c1211688 100644 --- a/integration-tests/oidc-client-wiremock/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java +++ b/integration-tests/oidc-client-wiremock/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java @@ -37,7 +37,7 @@ public Map start() { "{\"access_token\":\"access_token_1\", \"expires_in\":4, \"refresh_token\":\"refresh_token_1\"}"))); server.stubFor(WireMock.post("/non-standard-tokens") .withHeader("X-Custom", matching("XCustomHeaderValue")) - .withRequestBody(matching("grant_type=password&username=alice&password=alice")) + .withRequestBody(matching("grant_type=password&username=alice&password=alice&extra_param=extra_param_value")) .willReturn(WireMock .aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON)