Skip to content

Conversation

@danfitzgerald
Copy link

This pull adds a photos field to profile. Picture according to OpenID specification should contain a url to a users profile picture.

This pull should also solve this issue on passport-google-oidc.

The pull modifies relevant tests that check the validity of the profile field.

@danfitzgerald
Copy link
Author

@jaredhanson, is there anything left to do to get this merged?

This is my first PR!

@kothariji
Copy link

kothariji commented May 7, 2024

@jaredhanson any updates on this PR ?

or are there any other alternates/overrides to get the Picture of user in profile

@YasharF
Copy link

YasharF commented Jan 30, 2025

Instead of just the profile field, can you add the fields in the standard: https://openid.net/specs/openid-connect-basic-1_0.html#StandardClaims

You would probably end up with something like:

exports.parse = function(json) {
  var profile = {};
  profile.id = json.sub;
  // Prior to OpenID Connect Basic Client Profile 1.0 - draft 22, the "sub"
  // claim was named "user_id".  Many providers still use the old name, so
  // fallback to that.
  if (!profile.id) {
    profile.id = json.user_id;
  }
  
  if (json.name) { profile.displayName = json.name; }
  if (json.preferred_username) { profile.username = json.preferred_username; }
  if (json.family_name || json.given_name || json.middle_name) {
    profile.name = {};
    if (json.family_name) { profile.name.familyName = json.family_name; }
    if (json.given_name) { profile.name.givenName = json.given_name; }
    if (json.middle_name) { profile.name.middleName = json.middle_name; }
  }
  if (json.nickname) { profile.nickname = json.nickname; };
  if (json.preferred_username) { profile.preferred_username = json.preferred_username; };
  if (json.profile) { profile.profile = json.profile; };
  if (json.picture) { profile.photos = json.picture; }
  if (json.picture) { profile.photos = json.picture; }
  if (json.email) { profile.emails = [ { value: json.email } ]; }
  if (json.email_verified) { profile.email_verified = json.email_verified; }
  if (json.gender) { profile.gender = json.gender; };
  if (json.birthdate) { profile.birthdate = json.birthdate; };
  if (json.zoneinfo) { profile.zoneinfo = json.zoneinfo; };
  if (json.locale) { profile.locale = json.locale; }
  if (json.phone_number) { profile.phone_number = json.phone_number; };
  if (json.phone_number_verified) { profile.phone_number_verified = json.phone_number_verified; };
  if (json.address) { profile.address = json.address; };
  if (json.updated_at) { profile.updated_at = json.updated_at; };
  
  return profile;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants