Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/OpenIddict.Abstractions/OpenIddictConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ public static class Scopes
public const string Phone = "phone";
public const string Profile = "profile";
public const string Roles = "roles";
public const string Name = "name";
}

public static class Separators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,18 @@ public ValueTask HandleAsync(ExtractUserInfoResponseContext context)
}
}

// Note: Apple returns a non-standard "name" claim formatted as a JSON object.
else if (context.Registration.ProviderType is ProviderTypes.Apple)
{
var name = context.Response[Claims.Name];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I don't think it does what you want: this handler exclusively deals with parameters present in the userinfo response, not the authorization response. Unless Apple has decided to fix their horrible implementation, the user node is part of the authorization response, not the userinfo response.

if (name is not null)
{
context.Response[Claims.Name] = $"{name?["firstName"]} {name?["lastName"]}";
context.Response[Claims.FamilyName] = name?["lastName"];
context.Response[Claims.GivenName] = name?["firstName"];
}
}

return ValueTask.CompletedTask;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ public ValueTask HandleAsync(ProcessChallengeContext context)
context.ResponseMode = context.Registration.ProviderType switch
{
// Note: Apple requires using form_post when the "email" or "name" scopes are requested.
ProviderTypes.Apple when context.Scopes.Contains(Scopes.Email) || context.Scopes.Contains("name")
ProviderTypes.Apple when context.Scopes.Contains(Scopes.Email) || context.Scopes.Contains(Scopes.Name)
=> ResponseModes.FormPost,

_ => context.ResponseMode
Expand Down
Loading