-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrated pull request from rposener for SQL storage provider for We…
…bHook registrations!
- Loading branch information
rposener
authored and
Henrik Frystyk Nielsen
committed
Oct 31, 2015
1 parent
73f0c0d
commit 7464765
Showing
27 changed files
with
1,597 additions
and
0 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
25 changes: 25 additions & 0 deletions
25
src/Microsoft.AspNet.WebHooks.Custom.SqlStorage/App.config
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,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | ||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> | ||
</configSections> | ||
<entityFramework> | ||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> | ||
<parameters> | ||
<parameter value="mssqllocaldb" /> | ||
</parameters> | ||
</defaultConnectionFactory> | ||
<providers> | ||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> | ||
</providers> | ||
</entityFramework> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
67 changes: 67 additions & 0 deletions
67
src/Microsoft.AspNet.WebHooks.Custom.SqlStorage/Extensions/HttpConfigurationExtensions.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,67 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.ComponentModel; | ||
using System.Data.Entity; | ||
using Microsoft.AspNet.DataProtection; | ||
using Microsoft.AspNet.WebHooks; | ||
using Microsoft.AspNet.WebHooks.Config; | ||
using Microsoft.AspNet.WebHooks.Diagnostics; | ||
using Microsoft.AspNet.WebHooks.Services; | ||
using Microsoft.AspNet.WebHooks.Storage; | ||
using Microsoft.Framework.DependencyInjection; | ||
|
||
namespace System.Web.Http | ||
{ | ||
/// <summary> | ||
/// Extension methods for <see cref="HttpConfiguration"/>. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static class HttpConfigurationExtensions | ||
{ | ||
private const string ApplicationName = "Microsoft.AspNet.WebHooks"; | ||
private const string Purpose = "WebHookPersistence"; | ||
private const string DataProtectionKeysFolderName = "DataProtection-Keys"; | ||
|
||
/// <summary> | ||
/// Configures a Microsoft SQL Server Storage implementation of <see cref="IWebHookStore"/> | ||
/// which provides a persistent store for registered WebHooks used by the custom WebHooks module. | ||
/// </summary> | ||
/// <param name="config">The current <see cref="HttpConfiguration"/>config.</param> | ||
public static void InitializeCustomWebHooksSqlStorage(this HttpConfiguration config) | ||
{ | ||
if (config == null) | ||
{ | ||
throw new ArgumentNullException("config"); | ||
} | ||
|
||
WebHooksConfig.Initialize(config); | ||
|
||
ILogger logger = config.DependencyResolver.GetLogger(); | ||
SettingsDictionary settings = config.DependencyResolver.GetSettings(); | ||
|
||
// We explicitly set the DB initializer to null to avoid that an existing DB is initialized wrongly. | ||
Database.SetInitializer<WebHookContext>(null); | ||
|
||
IDataProtectionProvider provider = GetDataProtectionProvider(); | ||
IDataProtector protector = provider.CreateProtector(Purpose); | ||
|
||
IWebHookStore store = new SqlWebHookStore(settings, protector, logger); | ||
CustomServices.SetStore(store); | ||
} | ||
|
||
/// <summary> | ||
/// This follows the same initialization that is provided when <see cref="IDataProtectionProvider"/> | ||
/// is initialized within ASP.NET 5.0 Dependency Injection. | ||
/// </summary> | ||
/// <returns>A fully initialized <see cref="IDataProtectionProvider"/>.</returns> | ||
internal static IDataProtectionProvider GetDataProtectionProvider() | ||
{ | ||
ServiceCollection serviceCollection = new ServiceCollection(); | ||
serviceCollection.AddDataProtection(); | ||
IServiceProvider services = serviceCollection.BuildServiceProvider(); | ||
return services.GetDataProtectionProvider(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+926 Bytes
src/Microsoft.AspNet.WebHooks.Custom.SqlStorage/GlobalSuppressions.cs
Binary file not shown.
161 changes: 161 additions & 0 deletions
161
...soft.AspNet.WebHooks.Custom.SqlStorage/Microsoft.AspNet.WebHooks.Custom.SqlStorage.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,161 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebHooks.sln))\tools\WebHooks.settings.targets" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{EAC99E25-F698-41B2-8671-740D642781AB}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Microsoft.AspNet.WebHooks</RootNamespace> | ||
<AssemblyName>Microsoft.AspNet.WebHooks.Custom.SqlStorage</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> | ||
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile> | ||
<RunCodeAnalysis>$(CodeAnalysis)</RunCodeAnalysis> | ||
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions> | ||
<CodeAnalysisRuleSet>..\..\FxCop.ruleset</CodeAnalysisRuleSet> | ||
<DefineConstants>$(DefineConstants);ASPNETWEBHOOKS</DefineConstants> | ||
<SignAssembly>false</SignAssembly> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.AspNet.Cryptography.Internal, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.AspNet.Cryptography.Internal.1.0.0-beta6\lib\net451\Microsoft.AspNet.Cryptography.Internal.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.AspNet.DataProtection, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.AspNet.DataProtection.1.0.0-beta6\lib\net451\Microsoft.AspNet.DataProtection.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.AspNet.DataProtection.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.AspNet.DataProtection.Abstractions.1.0.0-beta6\lib\net451\Microsoft.AspNet.DataProtection.Abstractions.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Framework.Configuration, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Framework.Configuration.1.0.0-beta6\lib\net45\Microsoft.Framework.Configuration.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Framework.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Framework.Configuration.Abstractions.1.0.0-beta6\lib\net45\Microsoft.Framework.Configuration.Abstractions.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Framework.Configuration.Binder, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Framework.Configuration.Binder.1.0.0-beta6\lib\net45\Microsoft.Framework.Configuration.Binder.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Framework.DependencyInjection, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Framework.DependencyInjection.1.0.0-beta5\lib\net45\Microsoft.Framework.DependencyInjection.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Framework.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Framework.DependencyInjection.Abstractions.1.0.0-beta6\lib\net45\Microsoft.Framework.DependencyInjection.Abstractions.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Framework.Logging.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Framework.Logging.Abstractions.1.0.0-beta6\lib\net45\Microsoft.Framework.Logging.Abstractions.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Framework.OptionsModel, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Framework.OptionsModel.1.0.0-beta6\lib\net45\Microsoft.Framework.OptionsModel.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System.Security" /> | ||
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Common\CommonAssemblyInfo.cs"> | ||
<Link>Properties\CommonAssemblyInfo.cs</Link> | ||
</Compile> | ||
<Compile Include="GlobalSuppressions.cs" /> | ||
<Compile Include="Migrations\201510210452218_WebHooksInitialDb.cs" /> | ||
<Compile Include="Migrations\201510210452218_WebHooksInitialDb.Designer.cs"> | ||
<DependentUpon>201510210452218_WebHooksInitialDb.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Migrations\Configuration.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Properties\SqlStorageResources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>SqlStorageResources.resx</DependentUpon> | ||
</Compile> | ||
<Compile Include="Storage\Registration.cs" /> | ||
<Compile Include="Storage\WebHookContext.cs" /> | ||
<Compile Include="Extensions\HttpConfigurationExtensions.cs" /> | ||
<Compile Include="WebHooks\SqlWebHookStore.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Migrations\201510210452218_WebHooksInitialDb.resx"> | ||
<DependentUpon>201510210452218_WebHooksInitialDb.cs</DependentUpon> | ||
<ExcludeFromStyleCop>True</ExcludeFromStyleCop> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Properties\SqlStorageResources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>SqlStorageResources.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config"> | ||
<SubType>Designer</SubType> | ||
</None> | ||
<None Include="Microsoft.AspNet.WebHooks.Custom.SqlStorage.nuspec" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.AspNet.WebHooks.Common\Microsoft.AspNet.WebHooks.Common.csproj"> | ||
<Project>{f7dd0935-6320-4efc-9464-d5a2d2b8c2f7}</Project> | ||
<Name>Microsoft.AspNet.WebHooks.Common</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Microsoft.AspNet.WebHooks.Custom\Microsoft.AspNet.WebHooks.Custom.csproj"> | ||
<Project>{d4d210c6-3283-4d1d-806e-8717d8f51179}</Project> | ||
<Name>Microsoft.AspNet.WebHooks.Custom</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<CodeAnalysisDictionary Include="..\..\CustomDictionary.xml"> | ||
<Link>CustomDictionary.xml</Link> | ||
</CodeAnalysisDictionary> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets" Condition="Exists('..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets'))" /> | ||
</Target> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
20 changes: 20 additions & 0 deletions
20
...soft.AspNet.WebHooks.Custom.SqlStorage/Microsoft.AspNet.WebHooks.Custom.SqlStorage.nuspec
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,20 @@ | ||
<?xml version="1.0"?> | ||
<package > | ||
<metadata> | ||
<id>$id$</id> | ||
<version>$symversion$</version> | ||
<title>Microsoft ASP.NET Custom WebHooks SQL Module</title> | ||
<authors>Microsoft</authors> | ||
<owners>Microsoft, aspnet</owners> | ||
<licenseUrl>http://www.microsoft.com/web/webpi/eula/net_library_eula_ENU.htm</licenseUrl> | ||
<projectUrl>http://www.asp.net/</projectUrl> | ||
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl> | ||
<requireLicenseAcceptance>true</requireLicenseAcceptance> | ||
<description> | ||
This package provides support for persisting your custom WebHooks registrations in a SQL database. | ||
</description> | ||
<releaseNotes></releaseNotes> | ||
<copyright>© Microsoft Corporation. All rights reserved</copyright> | ||
<tags>Microsoft AspNet WebApi AspNetWebApi WebHooks</tags> | ||
</metadata> | ||
</package> |
29 changes: 29 additions & 0 deletions
29
...spNet.WebHooks.Custom.SqlStorage/Migrations/201510210452218_WebHooksInitialDb.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.