Skip to content

Commit

Permalink
- Fixes 3181 (#3183)
Browse files Browse the repository at this point in the history
* - Fixes 3181
- Removes the need to provide the MSAL redirect URI in web apps
- Updates the binding redirect in the OWIN samples

* Addressing PR feedback
  • Loading branch information
jmprieur authored Jan 7, 2025
1 parent fa46329 commit 2dd962b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 31 deletions.
6 changes: 6 additions & 0 deletions src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ public static IAppBuilder AddMicrosoftIdentityWebApp(
}
context.ProtocolMessage.SetParameter(ClaimConstants.ClientInfo, Constants.One);
context.ProtocolMessage.SetParameter(Constants.TelemetryHeaderKey, IdHelper.CreateTelemetryInfo());

if (context.ProtocolMessage.IssuerAddress != null && context.ProtocolMessage.IssuerAddress.EndsWith("/authorize", StringComparison.OrdinalIgnoreCase))
{
context.ProtocolMessage.RedirectUri = context.Request.Uri.ToString();
}

return Task.CompletedTask;
},

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/Microsoft.Identity.Web.OWIN/OwinTokenAcquirerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Web.Hosts;
Expand Down Expand Up @@ -34,7 +35,8 @@ protected override string DefineConfiguration(IConfigurationBuilder builder)
["AzureAd:SignedOutCallbackPath"] = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"],
["AzureAd:RedirectUri"] = ConfigurationManager.AppSettings["ida:RedirectUri"],
});
return HttpContext.Current.Request.PhysicalApplicationPath;

return HostingEnvironment.MapPath("~/");
}

/// <summary>
Expand Down
5 changes: 0 additions & 5 deletions tests/DevApps/aspnet-mvc/OwinWebApi/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
<assemblyIdentity name="WebGrease" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
Expand Down Expand Up @@ -180,7 +176,6 @@
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="EB42632606E9261F" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
</dependentAssembly>

</assemblyBinding>
</runtime>
<system.codedom>
Expand Down
14 changes: 0 additions & 14 deletions tests/DevApps/aspnet-mvc/OwinWebApp/App_Start/Startup.Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,10 @@ public void ConfigureAuth(IAppBuilder app)

app.AddMicrosoftIdentityWebApp(factory);
factory.Services
.Configure<ConfidentialClientApplicationOptions>(options => { options.RedirectUri = "https://localhost:44386/"; })
.AddMicrosoftGraph()
.AddDownstreamApi("DownstreamAPI1", factory.Configuration.GetSection("DownstreamAPI"))
.AddInMemoryTokenCaches();
factory.Build();

/*
app.AddMicrosoftIdentityWebApp(configureServices: services =>
{
services
.Configure<ConfidentialClientApplicationOptions>(options => { options.RedirectUri = "https://localhost:44386/"; })
.AddMicrosoftGraph()
// WE cannot do that today: Configuration is not available.
// .AddDownstreamApi("CalledApi", null)
.AddInMemoryTokenCaches();
});
*/

}
}
}
17 changes: 9 additions & 8 deletions tests/DevApps/aspnet-mvc/OwinWebApp/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.4" newVersion="8.0.0.4"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.5" newVersion="8.0.0.5"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
Expand Down Expand Up @@ -59,7 +59,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
Expand All @@ -75,31 +75,31 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.WsFederation" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.OpenIdConnect" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Logging" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Abstractions" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Identity.Client" publicKeyToken="0A613F4DD989E8AE" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.65.2.0" newVersion="4.65.2.0"/>
<bindingRedirect oldVersion="0.0.0.0-4.66.1.0" newVersion="4.66.1.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="ADB9793829DDAE60" culture="neutral"/>
Expand Down Expand Up @@ -170,6 +170,7 @@
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
</dependentAssembly>


</assemblyBinding>
</runtime>
<system.codedom>
Expand Down

0 comments on commit 2dd962b

Please sign in to comment.