From 9751636735d240ca1dbb3e0593e2302b7b8f95cb Mon Sep 17 00:00:00 2001 From: Steve Riesenberg <5248162+sjohnr@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:21:22 -0600 Subject: [PATCH] Polish gh-12281 --- .../ROOT/pages/reactive/oauth2/login/advanced.adoc | 7 ++++--- .../ROOT/pages/servlet/oauth2/login/advanced.adoc | 10 ++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc b/docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc index e623b58559..4b6391eeda 100644 --- a/docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc +++ b/docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc @@ -521,9 +521,10 @@ class OAuth2LoginSecurityConfig { // 3) Create a copy of oidcUser but use the mappedAuthorities instead val providerDetails = userRequest.getClientRegistration().getProviderDetails() val userNameAttributeName = providerDetails.getUserInfoEndpoint().getUserNameAttributeName() - val mappedOidcUser = when (StringUtils.hasText(userNameAttributeName)) { - true -> DefaultOidcUser(mappedAuthorities, oidcUser.idToken, oidcUser.userInfo, userNameAttributeName) - false -> DefaultOidcUser(mappedAuthorities, oidcUser.idToken, oidcUser.userInfo) + val mappedOidcUser = if (StringUtils.hasText(userNameAttributeName)) { + DefaultOidcUser(mappedAuthorities, oidcUser.idToken, oidcUser.userInfo, userNameAttributeName) + } else { + DefaultOidcUser(mappedAuthorities, oidcUser.idToken, oidcUser.userInfo) } Mono.just(mappedOidcUser) diff --git a/docs/modules/ROOT/pages/servlet/oauth2/login/advanced.adoc b/docs/modules/ROOT/pages/servlet/oauth2/login/advanced.adoc index fe7d4b373c..53c9381026 100644 --- a/docs/modules/ROOT/pages/servlet/oauth2/login/advanced.adoc +++ b/docs/modules/ROOT/pages/servlet/oauth2/login/advanced.adoc @@ -700,7 +700,7 @@ class OAuth2LoginSecurityConfig { return OAuth2UserService { userRequest -> // Delegate to the default implementation for loading a user - var oidcUser = delegate.loadUser(userRequest) + val oidcUser = delegate.loadUser(userRequest) val accessToken = userRequest.accessToken val mappedAuthorities = HashSet() @@ -712,12 +712,10 @@ class OAuth2LoginSecurityConfig { val providerDetails = userRequest.getClientRegistration().getProviderDetails() val userNameAttributeName = providerDetails.getUserInfoEndpoint().getUserNameAttributeName() if (StringUtils.hasText(userNameAttributeName)) { - oidcUser = DefaultOidcUser(mappedAuthorities, oidcUser.idToken, oidcUser.userInfo, userNameAttributeName) - else { - oidcUser = DefaultOidcUser(mappedAuthorities, oidcUser.idToken, oidcUser.userInfo) + DefaultOidcUser(mappedAuthorities, oidcUser.idToken, oidcUser.userInfo, userNameAttributeName) + } else { + DefaultOidcUser(mappedAuthorities, oidcUser.idToken, oidcUser.userInfo) } - - oidcUser } } }