Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions AspNet.Security.OAuth.Providers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.Docus
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.Zoho", "src\AspNet.Security.OAuth.Zoho\AspNet.Security.OAuth.Zoho.csproj", "{CD56ABE4-1CD2-4029-B556-E110A31A2CC4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.VkId", "src\AspNet.Security.OAuth.VkId\AspNet.Security.OAuth.VkId.csproj", "{F3E62C24-5F82-4CF5-A994-0E10D04FB495}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -721,6 +723,10 @@ Global
{CD56ABE4-1CD2-4029-B556-E110A31A2CC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD56ABE4-1CD2-4029-B556-E110A31A2CC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD56ABE4-1CD2-4029-B556-E110A31A2CC4}.Release|Any CPU.Build.0 = Release|Any CPU
{F3E62C24-5F82-4CF5-A994-0E10D04FB495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3E62C24-5F82-4CF5-A994-0E10D04FB495}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3E62C24-5F82-4CF5-A994-0E10D04FB495}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3E62C24-5F82-4CF5-A994-0E10D04FB495}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -833,6 +839,7 @@ Global
{55975423-C9C0-4C47-AD00-0F012F30AD3C} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{4E96BD06-04CD-4014-BA42-10D2CDB820D6} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{CD56ABE4-1CD2-4029-B556-E110A31A2CC4} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{F3E62C24-5F82-4CF5-A994-0E10D04FB495} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C7B54DE2-6407-4802-AD9C-CE54BF414C8C}
Expand Down
22 changes: 22 additions & 0 deletions src/AspNet.Security.OAuth.VkId/AspNet.Security.OAuth.VkId.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<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 src/AspNet.Security.OAuth.VkId/VkIdAuthenticationConstants.cs
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 src/AspNet.Security.OAuth.VkId/VkIdAuthenticationDefaults.cs
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 const string AuthenticationScheme = "VK ID";

/// <summary>
/// Default value for <see cref="AuthenticationScheme.DisplayName"/>.
/// </summary>
public const string DisplayName = "VK ID";

/// <summary>
/// Default value for <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
/// </summary>
public const string ClaimsIssuer = "VK ID";

/// <summary>
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
/// </summary>
public const string CallbackPath = "/signin-vkid";

/// <summary>
/// Default value for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
/// </summary>
public const string AuthorizationEndpoint = "https://id.vk.com/authorize";

/// <summary>
/// Default value for <see cref="OAuthOptions.TokenEndpoint"/>.
/// </summary>
public const string TokenEndpoint = "https://id.vk.com/oauth2/auth";

/// <summary>
/// Default value for <see cref="OAuthOptions.UserInformationEndpoint"/>.
/// </summary>
public const string UserInformationEndpoint = "https://id.vk.com/oauth2/user_info";
}
19 changes: 19 additions & 0 deletions src/AspNet.Security.OAuth.VkId/VkIdAuthenticationErrors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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;

public static class VkIdAuthenticationErrors
{
public const string InvalidOAuthState = "The oauth state was missing or invalid.";
public const string CorrelationFailed = "Correlation failed.";
public const string MissingCode = "Code was not found.";
public const string MissingDeviceId = "DeviceId was not found.";
public const string MissingCodeVerifierKey = "Code verifier key was not found.";
public const string MissingAccessToken = "Failed to retrieve access_token.";
public const string MissingRefreshToken = "Failed to retrieve refresh_token.";
public const string FailedToRetrieveUserInfo = "Failed to retrieve user information.";
}
74 changes: 74 additions & 0 deletions src/AspNet.Security.OAuth.VkId/VkIdAuthenticationExtensions.cs
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 Vkontakte authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddVkId(this AuthenticationBuilder builder)
{
return builder.AddVkId(VkIdAuthenticationDefaults.AuthenticationScheme, options => { });
}

/// <summary>
/// Adds <see cref="VkIdAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables Vkontakte authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <param name="configuration">The delegate used to configure the Vkontakte options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddVkId(
this AuthenticationBuilder builder,
Action<VkIdAuthenticationOptions> configuration)
{
return builder.AddVkId(VkIdAuthenticationDefaults.AuthenticationScheme, configuration);
}

/// <summary>
/// Adds <see cref="VkIdAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables Vkontakte 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 Vkontakte options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddVkId(
this AuthenticationBuilder builder,
string scheme,
Action<VkIdAuthenticationOptions> configuration)
{
return builder.AddVkId(scheme, VkIdAuthenticationDefaults.DisplayName, configuration);
}

/// <summary>
/// Adds <see cref="VkIdAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables Vkontakte 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 Vkontakte options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddVkId(
this AuthenticationBuilder builder,
string scheme,
[CanBeNull] string caption,
Action<VkIdAuthenticationOptions> configuration)
{
return builder.AddOAuth<VkIdAuthenticationOptions, VkIdAuthenticationHandler>(scheme, caption, configuration);
}
}
Loading