{"id":1214,"date":"2013-10-11T15:19:22","date_gmt":"2013-10-11T15:19:22","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2013\/10\/11\/securing-static-resources-with-windows-azure-active-directory-authentication\/"},"modified":"2013-10-11T15:19:22","modified_gmt":"2013-10-11T15:19:22","slug":"securing-static-resources-with-windows-azure-active-directory-authentication","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/securing-static-resources-with-windows-azure-active-directory-authentication\/","title":{"rendered":"Securing Static Resources with Windows Azure Active Directory Authentication"},"content":{"rendered":"<p>Visual Studio 2013 RC has a very useful feature of creating new ASP.NET application that are configured with Windows Azure Active Directory authentication. You can read more about it <a href=\"http:\/\/blogs.msdn.com\/b\/webdev\/archive\/2013\/09\/21\/organizational-accounts-in-visual-studio-2013-rc.aspx\">here<\/a><\/p>\n<p>If you open web.config file of such project that is secured with Windows Azure Active Directory, you will see following section:<\/p>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:88e9e7d4-2597-4bc5-81f1-3cdeac8fc6ae\" class=\"wlWriterEditableSmartContent\" style=\"margin: 0px;padding: 0px;float: none\">\n<div style=\"border: #000080 1px solid;color: #000;font-family: 'Courier New', Courier, Monospace;font-size: 10pt\">\n<div style=\"background: #000080;color: #fff;font-family: Verdana, Tahoma, Arial, sans-serif;font-weight: bold;padding: 2px 5px\">Code Snippet<\/div>\n<div style=\"background: #ddd;max-height: 300px;overflow: auto\">\n<ol start=\"1\" style=\"background: #ffffff;margin: 0 0 0 2em;padding: 0 0 0 5px\">\n<li><span style=\"background:#ffffff;color:#0000ff\"> &lt;<\/span><span style=\"background:#ffffff;color:#a31515\">modules<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<li style=\"background: #f3f3f3\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#a31515\">add<\/span><span style=\"background:#ffffff;color:#0000ff\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">name<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\">WSFederationAuthenticationModule<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">type<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\">System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">preCondition<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\">managedHandler<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\"> \/&gt;<\/span><\/li>\n<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#a31515\">add<\/span><span style=\"background:#ffffff;color:#0000ff\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">name<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\">SessionAuthenticationModule<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">type<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\">System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">preCondition<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\">managedHandler<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\"> \/&gt;<\/span><\/li>\n<li style=\"background: #f3f3f3\">&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"background:#ffffff;color:#0000ff\">&lt;\/<\/span><span style=\"background:#ffffff;color:#a31515\">modules<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<p>As you might know, WSFederationAuthenticationModule is the one that is responsible for authenticating incoming requests. However, this module runs only for those requests that go through ASP.NET pipeline. To enable it for all the incoming requests, including those for static files like images, you will have to enable RAMMFAR setting as below:<\/p>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fafd179e-3c94-4fd8-a934-b8fdf01a90cb\" class=\"wlWriterEditableSmartContent\" style=\"margin: 0px;padding: 0px;float: none\">\n<div style=\"border: #000080 1px solid;color: #000;font-family: 'Courier New', Courier, Monospace;font-size: 10pt\">\n<div style=\"background: #000080;color: #fff;font-family: Verdana, Tahoma, Arial, sans-serif;font-weight: bold;padding: 2px 5px\">Code Snippet<\/div>\n<div style=\"background: #ddd;max-height: 300px;overflow: auto\">\n<ol start=\"1\" style=\"background: #ffffff;margin: 0 0 0 2em;padding: 0 0 0 5px\">\n<li><span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#a31515\">modules<\/span><span style=\"background:#ffffff;color:#0000ff\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">runAllManagedModulesForAllRequests<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\">true<\/span><span style=\"background:#ffffff;color:#000000\">&#8220;<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<p>This way you can secure your entire application with WSFederationAuthenticationModule. <\/p>\n<p>Note that RAMMFAR generally has performance implications. It should be turned on only if static resources in a website need to be secured with Windows Azure Active Directory authentication. <\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio 2013 RC has a very useful feature of creating new ASP.NET application that are configured with Windows Azure Active Directory authentication. You can read more about it here If you open web.config file of such project that is secured with Windows Azure Active Directory, you will see following section: Code Snippet &lt;modules&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;add [&hellip;]<\/p>\n","protected":false},"author":3340,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[],"class_list":["post-1214","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet"],"acf":[],"blog_post_summary":"<p>Visual Studio 2013 RC has a very useful feature of creating new ASP.NET application that are configured with Windows Azure Active Directory authentication. You can read more about it here If you open web.config file of such project that is secured with Windows Azure Active Directory, you will see following section: Code Snippet &lt;modules&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;add [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/3340"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=1214"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1214\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=1214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=1214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=1214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}