Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add YahooClaimTypes
  • Loading branch information
khellang committed Feb 15, 2018
commit c4b7113a39bc7b5fc62218a140eed8e0139e167d
8 changes: 4 additions & 4 deletions src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public YahooAuthenticationOptions()

ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "guid");
ClaimActions.MapJsonKey(ClaimTypes.Name, "nickname");
ClaimActions.MapJsonKey("urn:yahoo:familyname", "familyName");
ClaimActions.MapJsonKey("urn:yahoo:givenname", "givenName");
ClaimActions.MapJsonKey("urn:yahoo:profile", "profileUrl");
ClaimActions.MapJsonKey("urn:yahoo:profileimage", "imageUrl");
ClaimActions.MapJsonKey(YahooClaimTypes.FamilyName, "familyName");
ClaimActions.MapJsonKey(YahooClaimTypes.GivenName, "givenName");
Copy link
Contributor Author

@khellang khellang Feb 15, 2018

Choose a reason for hiding this comment

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

Is there a reason a lot of these are using custom claim types instead of the built-in ones, like ClaimTypes.GivenName, ClaimTypes.Surname, etc.? Same in a lot of other places.

Copy link
Member

Choose a reason for hiding this comment

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

Most likely an oversight (most of the aspnet-contrib providers have been written by different contributors, who may not be super familiar with all the built-in claim names).

FWIW, I try to avoid using the "legacy" WS-Fed claims as much as possible (because they're super long and make cookies/tokens bigger) but the MSFT OAuth2 providers use them when it's possible so we use them too for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, so as long as there's no transformations for them anywhere, it doesn't really matter? Or, it might even be better to use custom claim types because of the smaller size?

Copy link
Member

Choose a reason for hiding this comment

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

Let's go with the built-in ClaimTypes when we have a good constant for these claims. Consistency always wins, I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to change any claim types in this PR, as it would be a breaking change. Should we open an issue for later?

Copy link
Member

Choose a reason for hiding this comment

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

Breaking changes are kinda acceptable as we're still in RC. But yeah, separate PR if you prefer 👍

ClaimActions.MapJsonKey(YahooClaimTypes.ProfileUrl, "profileUrl");
ClaimActions.MapJsonKey(YahooClaimTypes.ImageUrl, "imageUrl");
}
}
}
22 changes: 22 additions & 0 deletions src/AspNet.Security.OAuth.Yahoo/YahooClaimTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
* for more information concerning the license and the contributors participating to this project.
*/

namespace AspNet.Security.OAuth.Yahoo
{
/// <summary>
/// Contains claim types specific to the <see cref="YahooAuthenticationHandler"/>.
/// </summary>
public static class YahooClaimTypes
{
public const string FamilyName = "urn:yahoo:familyname";

public const string GivenName = "urn:yahoo:givenname";

public const string ProfileUrl = "urn:yahoo:profile";

public const string ImageUrl = "urn:yahoo:profileimage";
}
}