Permalink
Browse files

Added code to refresh the issuer key when it changes

  • Loading branch information...
robdmoore committed Jun 28, 2014
1 parent 636205b commit 19c2d208a133960201b4e46c2d80561f21effede
Showing with 14 additions and 1 deletion.
  1. +13 −1 AzureAdMvcExample/App_Start/IdentityConfig.cs
  2. +1 −0 AzureAdMvcExample/Web.config
@@ -1,4 +1,7 @@
using System.IdentityModel.Claims;
using System;
using System.Configuration;
using System.IdentityModel.Claims;
using System.IdentityModel.Tokens;
using System.Web.Helpers;
namespace AzureAdMvcExample
@@ -8,6 +11,15 @@ public static class IdentityConfig
public static void ConfigureIdentity()
{
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Name;
RefreshIssuerKeys();
}
private static void RefreshIssuerKeys()
{
// http://msdn.microsoft.com/en-us/library/azure/dn641920.aspx
var configPath = AppDomain.CurrentDomain.BaseDirectory + "\\" + "Web.config";
var metadataAddress = ConfigurationManager.AppSettings["ida:FederationMetadataLocation"];
ValidatingIssuerNameRegistry.WriteToConfig(metadataAddress, configPath);
}
}
}
@@ -10,6 +10,7 @@
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="ida:AudienceUri" value="http://localhost:34999" />
<add key="ida:FederationMetadataLocation" value="https://login.windows.net/azureadmvcexample.onmicrosoft.com/FederationMetadata/2007-06/FederationMetadata.xml" />
<add key="AzureADTenant" value="azureadmvcexample.onmicrosoft.com" />
</appSettings>
<system.web>

0 comments on commit 19c2d20

Please sign in to comment.