JoshYates1980
JoshYates1980

Reputation: 3636

Azure Active Directory disable while developing localhost

Is there a way to disable or bypass Azure Active Directory while I'm developing my application? I've tried the following and it still redirects to AAD for authentication.

protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        //IdentityConfig.ConfigureIdentity(); commented out for dev. 12/12/2014
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }

    //private void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
    //{
    //    if (!String.IsNullOrEmpty(IdentityConfig.Realm))
    //    {
    //        e.SignInRequestMessage.Realm = IdentityConfig.Realm;
    //    }
    //}

I commented out the methods in the IdentityConfig.cs, still redirects to AAD.

Advice is much appricated.

This is my web.config:

<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:FederationMetadataLocation" value="https://login.windows.net/accountname.onmicrosoft.com/FederationMetadata/2007-06/FederationMetadata.xml" />
  <add key="ida:Realm" value="https://accountname.onmicrosoft.com/application.WebUI" />
  <add key="ida:AudienceUri" value="https://accountname.onmicrosoft.com/application.WebUI" />
  <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=accountname;AccountKey=+mykey==" />
</appSettings>


<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" />
  <remove name="ApplicationInsightsWebTracking" />
  <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<system.identityModel.services>
<federationConfiguration>
  <cookieHandler requireSsl="true" />
  <wsFederation passiveRedirectEnabled="true" issuer="https://login.windows.net/onalabama.onmicrosoft.com/wsfed" realm="https://onalabama.onmicrosoft.com/Procurement.WebUI" requireHttps="true" />
 </federationConfiguration>
 </system.identityModel.services>

Upvotes: 1

Views: 2281

Answers (1)

codingoutloud
codingoutloud

Reputation: 2155

This solution is not very general, but might be just want you want if you are deploying to Azure Web Sites. You can ask Azure Web Sites to enforce authentication with an AAD before allowing users to reach your site.

Basically, you can develop locally WITHOUT any AAD in your code, and deploy that way too. Authentication is instead configured for the Azure Web Site - no code needed - after you configure it on the CONFIG tab in the Azure portal.

Here is a nice writeup: http://azure.microsoft.com/blog/2014/11/13/azure-websites-authentication-authorization/

There are some current limitations (see the article), but I've found this handy in a few situations already.

Upvotes: 1

Related Questions