Permalink
Browse files

Added configuration for Windows Azure AD authentication

  • Loading branch information...
robdmoore committed Jun 26, 2014
1 parent edfec23 commit 3c55318f24455884b6186fe6a3904fdc3418c78a
@@ -0,0 +1,19 @@
+using System.Configuration;
+using Microsoft.Owin.Security.ActiveDirectory;
+using Owin;
+
+namespace AzureAdMvcExample
+{
+ public class Startup
+ {
+ public void Configuration(IAppBuilder app)
+ {
+ app.UseWindowsAzureActiveDirectoryBearerAuthentication(
+ new WindowsAzureActiveDirectoryBearerAuthenticationOptions
+ {
+ Audience = ConfigurationManager.AppSettings["ida:AudienceUri"],
+ Tenant = ConfigurationManager.AppSettings["AzureADTenant"]
+ });
+ }
+ }
+}
@@ -62,6 +62,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.Drawing" />
+ <Reference Include="System.IdentityModel" />
+ <Reference Include="System.identitymodel.services" />
<Reference Include="System.IdentityModel.Tokens.Jwt">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.1.0.0\lib\net45\System.IdentityModel.Tokens.Jwt.dll</HintPath>
</Reference>
@@ -136,6 +138,7 @@
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
+ <Compile Include="App_Start\Startup.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
@@ -1,15 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
+ <configSections>
+ <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
+ <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
+ </configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
+ <add key="ida:AudienceUri" value="http://localhost:34999" />
+ <add key="AzureADTenant" value="azureadmvcexample.onmicrosoft.com" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
+ <system.webServer>
+ <modules>
+ <add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
+ <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
+ </modules>
+ </system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
@@ -34,4 +46,32 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
+ <system.identityModel>
+ <identityConfiguration>
+ <issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
+ <authority name="https://sts.windows.net/a83a168d-d1ad-4bde-9b0a-ed570162e695/">
+ <keys>
+ <add thumbprint="0000000000000000000000000000000000000000" />
+ </keys>
+ <validIssuers>
+ <add name="https://sts.windows.net/a83a168d-d1ad-4bde-9b0a-ed570162e695/" />
+ </validIssuers>
+ </authority>
+ </issuerNameRegistry>
+ <audienceUris>
+ <add value="http://localhost:34999" />
+ </audienceUris>
+ <securityTokenHandlers>
+ <add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ </securityTokenHandlers>
+ <certificateValidation certificateValidationMode="None" />
+ </identityConfiguration>
+ </system.identityModel>
+ <system.identityModel.services>
+ <federationConfiguration>
+ <cookieHandler requireSsl="false" />
+ <wsFederation passiveRedirectEnabled="true" issuer="https://login.windows.net/azureadmvcexample.onmicrosoft.com/wsfed" realm="http://localhost:34999" requireHttps="false" />
+ </federationConfiguration>
+ </system.identityModel.services>
</configuration>

0 comments on commit 3c55318

Please sign in to comment.