From 15c2b156f19826bcebf4cc8af9e2511d84bb8673 Mon Sep 17 00:00:00 2001 From: Steve Riesenberg <5248162+sjohnr@users.noreply.github.com> Date: Fri, 11 Apr 2025 15:10:05 -0500 Subject: [PATCH] Update Client Authentication examples Closes gh-16925 987d9c9788ba0343f543083c87613fb5 --- .../oauth2/client/client-authentication.adoc | 57 ++++++------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/docs/modules/ROOT/pages/servlet/oauth2/client/client-authentication.adoc b/docs/modules/ROOT/pages/servlet/oauth2/client/client-authentication.adoc index 62197146c2..8a3a440366 100644 --- a/docs/modules/ROOT/pages/servlet/oauth2/client/client-authentication.adoc +++ b/docs/modules/ROOT/pages/servlet/oauth2/client/client-authentication.adoc @@ -27,7 +27,7 @@ spring: ... ---- -The following example shows how to configure `DefaultAuthorizationCodeTokenResponseClient` to disable URL encoding of the client credentials: +The following example shows how to configure `RestClientAuthorizationCodeTokenResponseClient` to disable URL encoding of the client credentials: [tabs] ====== @@ -39,13 +39,9 @@ DefaultOAuth2TokenRequestHeadersConverter h new DefaultOAuth2TokenRequestHeadersConverter<>(); headersConverter.setEncodeClientCredentials(false); -OAuth2AuthorizationCodeGrantRequestEntityConverter requestEntityConverter = - new OAuth2AuthorizationCodeGrantRequestEntityConverter(); -requestEntityConverter.setHeadersConverter(headersConverter); - -DefaultAuthorizationCodeTokenResponseClient tokenResponseClient = - new DefaultAuthorizationCodeTokenResponseClient(); -tokenResponseClient.setRequestEntityConverter(requestEntityConverter); +RestClientAuthorizationCodeTokenResponseClient tokenResponseClient = + new RestClientAuthorizationCodeTokenResponseClient(); +tokenResponseClient.setHeadersConverter(headersConverter); ---- Kotlin:: @@ -55,11 +51,8 @@ Kotlin:: val headersConverter = DefaultOAuth2TokenRequestHeadersConverter() headersConverter.setEncodeClientCredentials(false) -val requestEntityConverter = OAuth2AuthorizationCodeGrantRequestEntityConverter() -requestEntityConverter.setHeadersConverter(headersConverter) - -val tokenResponseClient = DefaultAuthorizationCodeTokenResponseClient() -tokenResponseClient.setRequestEntityConverter(requestEntityConverter) +val tokenResponseClient = RestClientAuthorizationCodeTokenResponseClient() +tokenResponseClient.setHeadersConverter(headersConverter) ---- ====== @@ -119,7 +112,7 @@ spring: ... ---- -The following example shows how to configure `DefaultAuthorizationCodeTokenResponseClient`: +The following example shows how to configure `RestClientAuthorizationCodeTokenResponseClient`: [tabs] ====== @@ -140,14 +133,10 @@ Function jwkResolver = (clientRegistration) -> { return null; }; -OAuth2AuthorizationCodeGrantRequestEntityConverter requestEntityConverter = - new OAuth2AuthorizationCodeGrantRequestEntityConverter(); -requestEntityConverter.addParametersConverter( +RestClientAuthorizationCodeTokenResponseClient tokenResponseClient = + new RestClientAuthorizationCodeTokenResponseClient(); +tokenResponseClient.addParametersConverter( new NimbusJwtClientAuthenticationParametersConverter<>(jwkResolver)); - -DefaultAuthorizationCodeTokenResponseClient tokenResponseClient = - new DefaultAuthorizationCodeTokenResponseClient(); -tokenResponseClient.setRequestEntityConverter(requestEntityConverter); ---- Kotlin:: @@ -168,13 +157,10 @@ val jwkResolver: Function = null } -val requestEntityConverter = OAuth2AuthorizationCodeGrantRequestEntityConverter() -requestEntityConverter.addParametersConverter( +val tokenResponseClient = RestClientAuthorizationCodeTokenResponseClient() +tokenResponseClient.addParametersConverter( NimbusJwtClientAuthenticationParametersConverter(jwkResolver) ) - -val tokenResponseClient = DefaultAuthorizationCodeTokenResponseClient() -tokenResponseClient.setRequestEntityConverter(requestEntityConverter) ---- ====== @@ -198,7 +184,7 @@ spring: ... ---- -The following example shows how to configure `DefaultClientCredentialsTokenResponseClient`: +The following example shows how to configure `RestClientClientCredentialsTokenResponseClient`: [tabs] ====== @@ -218,14 +204,10 @@ Function jwkResolver = (clientRegistration) -> { return null; }; -OAuth2ClientCredentialsGrantRequestEntityConverter requestEntityConverter = - new OAuth2ClientCredentialsGrantRequestEntityConverter(); -requestEntityConverter.addParametersConverter( +RestClientClientCredentialsTokenResponseClient tokenResponseClient = + new RestClientClientCredentialsTokenResponseClient(); +tokenResponseClient.addParametersConverter( new NimbusJwtClientAuthenticationParametersConverter<>(jwkResolver)); - -DefaultClientCredentialsTokenResponseClient tokenResponseClient = - new DefaultClientCredentialsTokenResponseClient(); -tokenResponseClient.setRequestEntityConverter(requestEntityConverter); ---- Kotlin:: @@ -245,13 +227,10 @@ val jwkResolver = Function { clientRegistration: Clien null } -val requestEntityConverter = OAuth2ClientCredentialsGrantRequestEntityConverter() -requestEntityConverter.addParametersConverter( +val tokenResponseClient = RestClientClientCredentialsTokenResponseClient() +tokenResponseClient.addParametersConverter( NimbusJwtClientAuthenticationParametersConverter(jwkResolver) ) - -val tokenResponseClient = DefaultClientCredentialsTokenResponseClient() -tokenResponseClient.setRequestEntityConverter(requestEntityConverter) ---- ======