reta commented on code in PR #3304:
URL: https://github.com/apache/cxf/pull/3304#discussion_r3559782661


##########
rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/UserInfoService.java:
##########
@@ -98,35 +99,40 @@ protected Object convertUserInfoToResponseEntity(UserInfo 
userInfo) {
     }
 
     protected UserInfo createFromIdToken(IdToken idToken) {
+        return createFromIdToken(idToken, Collections.emptyList());
+    }
+
+    protected UserInfo createFromIdToken(IdToken idToken, List<String> scopes) 
{
         UserInfo userInfo = new UserInfo();
         userInfo.setSubject(idToken.getSubject());
 
         if (super.isJwsRequired()) {
             userInfo.setIssuer(idToken.getIssuer());
             userInfo.setAudience(idToken.getAudience());
         }
-        if (idToken.getPreferredUserName() != null) {
+        if (scopes.contains(OidcUtils.PROFILE_SCOPE) && 
idToken.getPreferredUserName() != null) {

Review Comment:
   Nit, we could probably move `scopes.contains(OidcUtils.PROFILE_SCOPE)` to 
own `if`:
   ```
   if (scopes.contains(OidcUtils.PROFILE_SCOPE)) {
     if ( idToken.getPreferredUserName() != null) {
        userInfo.setPreferredUserName(idToken.getPreferredUserName());
     }
     ...
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to