-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new provider for VK ID.
- Loading branch information
Showing
12 changed files
with
718 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/AspNet.Security.OAuth.VkId/AspNet.Security.OAuth.VkId.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<PackageValidationBaselineVersion>8.3.0</PackageValidationBaselineVersion> | ||
<TargetFrameworks>$(DefaultNetCoreTargetFramework)</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Description>ASP.NET Core security middleware enabling VK ID authentication.</Description> | ||
<Authors>hscokies</Authors> | ||
<PackageTags>aspnetcore;authentication;oauth;security;vkontakte;vkid</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
<PackageReference Include="JetBrains.Annotations" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<!-- TODO Enable once this provider is published to NuGet.org --> | ||
<PropertyGroup> | ||
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation> | ||
</PropertyGroup> | ||
</Project> |
24 changes: 24 additions & 0 deletions
24
src/AspNet.Security.OAuth.VkId/VkIdAuthenticationConstants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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.VkId; | ||
|
||
/// <summary> | ||
/// Contains constants specific to the <see cref="VkIdAuthenticationHandler"/>. | ||
/// </summary> | ||
public static class VkIdAuthenticationConstants | ||
{ | ||
public static class Claims | ||
{ | ||
public const string Avatar = "urn:vkid:avatar:link"; | ||
public const string IsVerified = "urn:vkid:verified"; | ||
} | ||
|
||
public static class AuthenticationProperties | ||
{ | ||
public const string DeviceId = "DeviceId"; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/AspNet.Security.OAuth.VkId/VkIdAuthenticationDefaults.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.VkId; | ||
|
||
/// <summary> | ||
/// Default values used by the VK ID authentication middleware. | ||
/// </summary> | ||
public static class VkIdAuthenticationDefaults | ||
{ | ||
/// <summary> | ||
/// Default value for <see cref="AuthenticationScheme.Name"/>. | ||
/// </summary> | ||
public static readonly string AuthenticationScheme = "VK ID"; | ||
|
||
/// <summary> | ||
/// Default value for <see cref="AuthenticationScheme.DisplayName"/>. | ||
/// </summary> | ||
public static readonly string DisplayName = "VK ID"; | ||
|
||
/// <summary> | ||
/// Default value for <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>. | ||
/// </summary> | ||
public static readonly string ClaimsIssuer = "VK ID"; | ||
|
||
/// <summary> | ||
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>. | ||
/// </summary> | ||
public static readonly string CallbackPath = "/signin-vkid"; | ||
|
||
/// <summary> | ||
/// Default value for <see cref="OAuthOptions.AuthorizationEndpoint"/>. | ||
/// </summary> | ||
public static readonly string AuthorizationEndpoint = "https://id.vk.com/authorize"; | ||
|
||
/// <summary> | ||
/// Default value for <see cref="OAuthOptions.TokenEndpoint"/>. | ||
/// </summary> | ||
public static readonly string TokenEndpoint = "https://id.vk.com/oauth2/auth"; | ||
|
||
/// <summary> | ||
/// Default value for <see cref="OAuthOptions.UserInformationEndpoint"/>. | ||
/// </summary> | ||
public static readonly string UserInformationEndpoint = "https://id.vk.com/oauth2/user_info"; | ||
} |
74 changes: 74 additions & 0 deletions
74
src/AspNet.Security.OAuth.VkId/VkIdAuthenticationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace AspNet.Security.OAuth.VkId; | ||
|
||
/// <summary> | ||
/// Extension methods to add VK ID authentication capabilities to an HTTP application pipeline. | ||
/// </summary> | ||
public static class VkIdAuthenticationExtensions | ||
{ | ||
/// <summary> | ||
/// Adds <see cref="VkIdAuthenticationHandler"/> to the specified | ||
/// <see cref="AuthenticationBuilder"/>, which enables VK ID authentication capabilities. | ||
/// </summary> | ||
/// <param name="builder">The authentication builder.</param> | ||
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns> | ||
public static AuthenticationBuilder AddVkId([NotNull] this AuthenticationBuilder builder) | ||
{ | ||
return builder.AddVkId(VkIdAuthenticationDefaults.AuthenticationScheme, _ => { }); | ||
} | ||
|
||
/// <summary> | ||
/// Adds <see cref="VkIdAuthenticationHandler"/> to the specified | ||
/// <see cref="AuthenticationBuilder"/>, which enables VK ID authentication capabilities. | ||
/// </summary> | ||
/// <param name="builder">The authentication builder.</param> | ||
/// <param name="configuration">The delegate used to configure the <see cref="VkIdAuthenticationOptions"/> options.</param> | ||
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns> | ||
public static AuthenticationBuilder AddVkId( | ||
[NotNull] this AuthenticationBuilder builder, | ||
[NotNull] Action<VkIdAuthenticationOptions> configuration) | ||
{ | ||
return builder.AddVkId(VkIdAuthenticationDefaults.AuthenticationScheme, configuration); | ||
} | ||
|
||
/// <summary> | ||
/// Adds <see cref="VkIdAuthenticationHandler"/> to the specified | ||
/// <see cref="AuthenticationBuilder"/>, which enables VK ID authentication capabilities. | ||
/// </summary> | ||
/// <param name="builder">The authentication builder.</param> | ||
/// <param name="scheme">The authentication scheme associated with this instance.</param> | ||
/// <param name="configuration">The delegate used to configure the <see cref="VkIdAuthenticationOptions"/> options.</param> | ||
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns> | ||
public static AuthenticationBuilder AddVkId( | ||
[NotNull] this AuthenticationBuilder builder, | ||
[NotNull] string scheme, | ||
[NotNull] Action<VkIdAuthenticationOptions> configuration) | ||
{ | ||
return builder.AddVkId(scheme, VkIdAuthenticationDefaults.DisplayName, configuration); | ||
} | ||
|
||
/// <summary> | ||
/// Adds <see cref="VkIdAuthenticationHandler"/> to the specified | ||
/// <see cref="AuthenticationBuilder"/>, which enables VK ID authentication capabilities. | ||
/// </summary> | ||
/// <param name="builder">The authentication builder.</param> | ||
/// <param name="scheme">The authentication scheme associated with this instance.</param> | ||
/// <param name="caption">The optional display name associated with this instance.</param> | ||
/// <param name="configuration">The delegate used to configure the <see cref="VkIdAuthenticationOptions"/> options.</param> | ||
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns> | ||
public static AuthenticationBuilder AddVkId( | ||
[NotNull] this AuthenticationBuilder builder, | ||
[NotNull] string scheme, | ||
[CanBeNull] string caption, | ||
[NotNull] Action<VkIdAuthenticationOptions> configuration) | ||
{ | ||
return builder.AddOAuth<VkIdAuthenticationOptions, VkIdAuthenticationHandler>(scheme, caption, configuration); | ||
} | ||
} |
Oops, something went wrong.