Skip to content

Commit

Permalink
fix(oidc): add name claim extraction (#3384)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoyce0510 committed Oct 14, 2021
1 parent 037c897 commit a25434c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion datahub-frontend/app/auth/sso/oidc/OidcCallbackLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,18 @@ private CorpUserSnapshot extractUser(CorpuserUrn urn, CommonProfile profile) {
String email = profile.getEmail();
URI picture = profile.getPictureUrl();
String displayName = profile.getDisplayName();
String fullName = (String) profile.getAttribute("name"); // Name claim is sometimes provided, including by Google.
if (fullName == null && firstName != null && lastName != null) {
fullName = String.format("%s %s", firstName, lastName);
}

// TODO: Support custom claims mapping. (e.g. department, title, etc)

final CorpUserInfo userInfo = new CorpUserInfo();
userInfo.setActive(true);
userInfo.setFirstName(firstName, SetMode.IGNORE_NULL);
userInfo.setLastName(lastName, SetMode.IGNORE_NULL);
userInfo.setFullName(String.format("%s %s", firstName, lastName), SetMode.IGNORE_NULL);
userInfo.setFullName(fullName, SetMode.IGNORE_NULL);
userInfo.setEmail(email, SetMode.IGNORE_NULL);
// If there is a display name, use it. Otherwise fall back to full name.
userInfo.setDisplayName(displayName == null ? userInfo.getFullName() : displayName, SetMode.IGNORE_NULL);
Expand Down

0 comments on commit a25434c

Please sign in to comment.