Update: Authorize User Roles with Attribute

Avoid overriding the Context.User in the http pipeline.
This commit is contained in:
Gary Sharp
2013-05-16 19:27:11 +10:00
parent f6904d27c9
commit 664cde59eb
22 changed files with 115 additions and 62 deletions
+13 -10
View File
@@ -46,14 +46,17 @@
<Reference Include="DotNet.Highcharts">
<HintPath>..\packages\DotNet.Highcharts.1.2\lib\DotNet.Highcharts.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.SignalR.Core">
<HintPath>..\packages\Microsoft.AspNet.SignalR.Core.1.0.1\lib\net40\Microsoft.AspNet.SignalR.Core.dll</HintPath>
<Reference Include="Microsoft.AspNet.SignalR.Core, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.SignalR.Core.1.1.0\lib\net40\Microsoft.AspNet.SignalR.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.SignalR.Owin">
<HintPath>..\packages\Microsoft.AspNet.SignalR.Owin.1.0.1\lib\net45\Microsoft.AspNet.SignalR.Owin.dll</HintPath>
<Reference Include="Microsoft.AspNet.SignalR.Owin, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.SignalR.Owin.1.1.0\lib\net45\Microsoft.AspNet.SignalR.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.SignalR.SystemWeb">
<HintPath>..\packages\Microsoft.AspNet.SignalR.SystemWeb.1.0.1\lib\net45\Microsoft.AspNet.SignalR.SystemWeb.dll</HintPath>
<Reference Include="Microsoft.AspNet.SignalR.SystemWeb, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.SignalR.SystemWeb.1.1.0\lib\net45\Microsoft.AspNet.SignalR.SystemWeb.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Owin.Host.SystemWeb">
@@ -61,7 +64,7 @@
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.5.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.5.0.5\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Owin">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
@@ -163,7 +166,7 @@
</Reference>
<Reference Include="T4MVCExtensions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=7b26dc2a43f6a0d4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\T4MVCExtensions.3.6.1\lib\net40\T4MVCExtensions.dll</HintPath>
<HintPath>..\packages\T4MVCExtensions.3.6.4\lib\net40\T4MVCExtensions.dll</HintPath>
</Reference>
<Reference Include="WebActivatorEx">
<HintPath>..\packages\WebActivatorEx.2.0.1\lib\net40\WebActivatorEx.dll</HintPath>
@@ -929,7 +932,7 @@
<None Include="ClientSource\Scripts\Modules\jQueryUI-DynaTree.js">
<DependentUpon>jQueryUI-DynaTree.js.bundle</DependentUpon>
</None>
<None Include="ClientSource\Scripts\Modules\jQuery-SignalR\jquery.signalR-1.0.1.js" />
<Content Include="ClientSource\Scripts\Modules\jQuery-SignalR\jquery.signalR-1.1.0.js" />
<Content Include="ClientSource\Scripts\Modules\jQueryUI-DynaTree.min.js">
<DependentUpon>jQueryUI-DynaTree.js.bundle</DependentUpon>
</Content>
@@ -1858,7 +1861,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<UserProperties BuildVersion_StartDate="2011/7/1" BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" />
<UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" BuildVersion_StartDate="2011/7/1" />
</VisualStudio>
</ProjectExtensions>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
-9
View File
@@ -21,7 +21,6 @@ namespace Disco.Web
{
public DiscoApplication()
{
base.AuthenticateRequest += new EventHandler(DiscoApplication_AuthenticateRequest);
base.BeginRequest += new EventHandler(DiscoApplication_BeginRequest);
base.Error += new EventHandler(DiscoApplication_Error);
}
@@ -125,14 +124,6 @@ namespace Disco.Web
}
#region Authentication
void DiscoApplication_AuthenticateRequest(object sender, EventArgs e)
{
User u = CurrentUser;
if (u != null)
{
base.Context.User = new GenericPrincipal(base.Context.User.Identity, new string[] { u.Type });
}
}
public static bool InitialConfig { get; set; }
+2 -2
View File
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.2.0513.1423")]
[assembly: AssemblyFileVersion("1.2.0513.1423")]
[assembly: AssemblyVersion("1.2.0516.1911")]
[assembly: AssemblyFileVersion("1.2.0516.1911")]