Skip to content

Commit c5d62fe

Browse files
MrMeisonkevinchalet
authored andcommitted
Fix the invalid extension method name and update the handler to include the recent API changes
1 parent 1b5140f commit c5d62fe

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ We would love it if you could help contributing to this repository. Please look
4242
* [Jesse Mandel](https://github.com/supergibbs)
4343
* [Jordan Knight](https://github.com/jakkaj)
4444
* [Kévin Chalet](https://github.com/PinpointTownes)
45+
* [Konstantin Mamaev](https://github.com/MrMeison)
4546
* [Mariusz Zieliński](https://github.com/mariozski)
4647
* [Maxime Roussin-Bélanger](https://github.com/Lorac)
4748
* [Michael Knowles](https://github.com/mjknowles)

src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static IApplicationBuilder UseVkontakteAuthentication(
4141
/// <param name="app">The <see cref="IApplicationBuilder"/> to add the middleware to.</param>
4242
/// <param name="configuration">An action delegate to configure the provided <see cref="VkontakteAuthenticationOptions"/>.</param>
4343
/// <returns>A reference to this instance after the operation has completed.</returns>
44-
public static IApplicationBuilder UseLinkedInAuthentication(
44+
public static IApplicationBuilder UseVkontakteAuthentication(
4545
[NotNull] this IApplicationBuilder app,
4646
[NotNull] Action<VkontakteAuthenticationOptions> configuration) {
4747
if (app == null) {

src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync([NotNull]
4949
identity.AddOptionalClaim(ClaimTypes.NameIdentifier, VkontakteAuthenticationHelper.GetId(user), Options.ClaimsIssuer)
5050
.AddOptionalClaim(ClaimTypes.GivenName, VkontakteAuthenticationHelper.GetFirstName(user), Options.ClaimsIssuer)
5151
.AddOptionalClaim(ClaimTypes.Surname, VkontakteAuthenticationHelper.GetLastName(user), Options.ClaimsIssuer)
52-
.AddOptionalClaim(ClaimTypes.Name, VkontakteAuthenticationHelper.GetScreenName(user), Options.ClaimsIssuer)
53-
.AddOptionalClaim("urn:vkontakte:link", VkontakteAuthenticationHelper.GetPhoto(user), Options.ClaimsIssuer);
52+
.AddOptionalClaim(ClaimTypes.Hash, VkontakteAuthenticationHelper.GetHash(user), Options.ClaimsIssuer)
53+
.AddOptionalClaim("urn:vkontakte:photo:link", VkontakteAuthenticationHelper.GetPhoto(user), Options.ClaimsIssuer)
54+
.AddOptionalClaim("urn:vkontakte:photo_thumb:link", VkontakteAuthenticationHelper.GetPhotoThumbnail(user), Options.ClaimsIssuer);
5455

5556
await Options.Events.CreatingTicket(context);
5657

src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHelper.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public static class VkontakteAuthenticationHelper {
1818
/// </summary>
1919
public static string GetId([NotNull] JObject user) => user.Value<string>("uid");
2020

21+
/// <summary>
22+
/// Gets the hash for checking authorization on the remote client.
23+
/// </summary>
24+
public static string GetHash([NotNull] JObject user) => user.Value<string>("hash");
25+
2126
/// <summary>
2227
/// Gets the first name associated with the logged in user.
2328
/// </summary>
@@ -29,13 +34,13 @@ public static class VkontakteAuthenticationHelper {
2934
public static string GetLastName([NotNull] JObject user) => user.Value<string>("last_name");
3035

3136
/// <summary>
32-
/// Gets the screen name associated with the logged in user.
37+
/// Gets the URL of the user profile picture.
3338
/// </summary>
34-
public static string GetScreenName([NotNull] JObject user) => user.Value<string>("screen_name");
39+
public static string GetPhoto([NotNull] JObject user) => user.Value<string>("photo");
3540

3641
/// <summary>
37-
/// Gets the photo associated with the logged in user.
42+
/// Gets the URL of the user profile thumbnail.
3843
/// </summary>
39-
public static string GetPhoto([NotNull] JObject user) => user.Value<string>("photo_50");
44+
public static string GetPhotoThumbnail([NotNull] JObject user) => user.Value<string>("photo_rec");
4045
}
4146
}

src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationOptions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ public VkontakteAuthenticationOptions() {
3636
"uid",
3737
"first_name",
3838
"last_name",
39-
"screen_name",
40-
"photo_50"
39+
"photo_rec",
40+
"photo",
41+
"hash"
4142
};
4243
}
4344
}

0 commit comments

Comments
 (0)