Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[oidc] user display names are all default when use google openid connect #4498

Closed
3 tasks done
krin-wang opened this issue Aug 3, 2022 · 5 comments
Closed
3 tasks done
Labels

Comments

@krin-wang
Copy link

krin-wang commented Aug 3, 2022

  • I have checked the discussions
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Describe the bug
oidc PreferredUsername is null when use google openid connect. I'd suggest fallback to FullName, when PreferredUsername is empty.

To Reproduce
Steps to reproduce the behavior:

  1. use google openid connect as oidc provider.
  2. login and check user display name
  3. all display names are default

Expected behavior
I'd like there is a valid user display name.

Screenshots
Screen Shot 2022-08-03 at 2 24 37 PM

@krin-wang
Copy link
Author

Based on #3795, we're using PreferredUsername as display name. Could we fallback to FullName when PreferredUsername is empty?

I did a few changes in local and tested.

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java

     newUserInfo.setName(oidcUser.getPreferredUsername());
+    if (!StringUtils.hasText(newUserInfo.getName())) {
+      newUserInfo.setName(oidcUser.getFullName());
+    }
     newUserInfo.setEmail(oidcUser.getEmail());

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcUserInfoHolder.java

       OidcUser oidcUser = (OidcUser) principal;
       userInfo.setUserId(oidcUser.getSubject());
       userInfo.setName(oidcUser.getPreferredUsername());
+      if (!StringUtils.hasText(userInfo.getName())) {
+        userInfo.setName(oidcUser.getFullName());
+      }
       userInfo.setEmail(oidcUser.getEmail());
       return userInfo;

@nobodyiam
Copy link
Member

I think it's reasonable, @vdisk-group what do you think?

@stale
Copy link

stale bot commented Sep 3, 2022

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 3, 2022
@nobodyiam nobodyiam removed the stale label Sep 4, 2022
@stale
Copy link

stale bot commented Oct 4, 2022

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 4, 2022
@stale
Copy link

stale bot commented Oct 11, 2022

This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants