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: Add "name" claim extraction if present #3384

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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