mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-26 01:18:20 +00:00
fix(oidc): add name claim extraction (#3384)
This commit is contained in:
parent
037c89763e
commit
a25434c81e
@ -185,6 +185,10 @@ public class OidcCallbackLogic extends DefaultCallbackLogic<Result, PlayWebConte
|
||||
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)
|
||||
|
||||
@ -192,7 +196,7 @@ public class OidcCallbackLogic extends DefaultCallbackLogic<Result, PlayWebConte
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user