Skip to content

Commit 2dd962b

Browse files
authored
- Fixes 3181 (#3183)
* - 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
1 parent fa46329 commit 2dd962b

File tree

6 files changed

+24
-31
lines changed

6 files changed

+24
-31
lines changed

src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ public static IAppBuilder AddMicrosoftIdentityWebApp(
161161
}
162162
context.ProtocolMessage.SetParameter(ClaimConstants.ClientInfo, Constants.One);
163163
context.ProtocolMessage.SetParameter(Constants.TelemetryHeaderKey, IdHelper.CreateTelemetryInfo());
164+
165+
if (context.ProtocolMessage.IssuerAddress != null && context.ProtocolMessage.IssuerAddress.EndsWith("/authorize", StringComparison.OrdinalIgnoreCase))
166+
{
167+
context.ProtocolMessage.RedirectUri = context.Request.Uri.ToString();
168+
}
169+
164170
return Task.CompletedTask;
165171
},
166172

src/Microsoft.Identity.Web.OWIN/Microsoft.Identity.Web.OWIN.xml

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.Identity.Web.OWIN/OwinTokenAcquirerFactory.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Configuration;
77
using System.Linq;
88
using System.Web;
9+
using System.Web.Hosting;
910
using Microsoft.Extensions.Configuration;
1011
using Microsoft.Extensions.DependencyInjection;
1112
using Microsoft.Identity.Web.Hosts;
@@ -34,7 +35,8 @@ protected override string DefineConfiguration(IConfigurationBuilder builder)
3435
["AzureAd:SignedOutCallbackPath"] = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"],
3536
["AzureAd:RedirectUri"] = ConfigurationManager.AppSettings["ida:RedirectUri"],
3637
});
37-
return HttpContext.Current.Request.PhysicalApplicationPath;
38+
39+
return HostingEnvironment.MapPath("~/");
3840
}
3941

4042
/// <summary>

tests/DevApps/aspnet-mvc/OwinWebApi/Web.config

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
<assemblyIdentity name="WebGrease" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
2525
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
2626
</dependentAssembly>
27-
<dependentAssembly>
28-
<assemblyIdentity name="System.ValueTuple" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
29-
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
30-
</dependentAssembly>
3127
<dependentAssembly>
3228
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
3329
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
@@ -180,7 +176,6 @@
180176
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="EB42632606E9261F" culture="neutral"/>
181177
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
182178
</dependentAssembly>
183-
184179
</assemblyBinding>
185180
</runtime>
186181
<system.codedom>

tests/DevApps/aspnet-mvc/OwinWebApp/App_Start/Startup.Auth.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,10 @@ public void ConfigureAuth(IAppBuilder app)
2121

2222
app.AddMicrosoftIdentityWebApp(factory);
2323
factory.Services
24-
.Configure<ConfidentialClientApplicationOptions>(options => { options.RedirectUri = "https://localhost:44386/"; })
2524
.AddMicrosoftGraph()
2625
.AddDownstreamApi("DownstreamAPI1", factory.Configuration.GetSection("DownstreamAPI"))
2726
.AddInMemoryTokenCaches();
2827
factory.Build();
29-
30-
/*
31-
app.AddMicrosoftIdentityWebApp(configureServices: services =>
32-
{
33-
services
34-
.Configure<ConfidentialClientApplicationOptions>(options => { options.RedirectUri = "https://localhost:44386/"; })
35-
.AddMicrosoftGraph()
36-
// WE cannot do that today: Configuration is not available.
37-
// .AddDownstreamApi("CalledApi", null)
38-
.AddInMemoryTokenCaches();
39-
});
40-
*/
41-
4228
}
4329
}
4430
}

tests/DevApps/aspnet-mvc/OwinWebApp/Web.config

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</dependentAssembly>
3232
<dependentAssembly>
3333
<assemblyIdentity name="System.Text.Json" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
34-
<bindingRedirect oldVersion="0.0.0.0-8.0.0.4" newVersion="8.0.0.4"/>
34+
<bindingRedirect oldVersion="0.0.0.0-8.0.0.5" newVersion="8.0.0.5"/>
3535
</dependentAssembly>
3636
<dependentAssembly>
3737
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
@@ -59,7 +59,7 @@
5959
</dependentAssembly>
6060
<dependentAssembly>
6161
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
62-
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
62+
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
6363
</dependentAssembly>
6464
<dependentAssembly>
6565
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
@@ -75,31 +75,31 @@
7575
</dependentAssembly>
7676
<dependentAssembly>
7777
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
78-
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
78+
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
7979
</dependentAssembly>
8080
<dependentAssembly>
8181
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.WsFederation" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
8282
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0"/>
8383
</dependentAssembly>
8484
<dependentAssembly>
8585
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.OpenIdConnect" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
86-
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
86+
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
8787
</dependentAssembly>
8888
<dependentAssembly>
8989
<assemblyIdentity name="Microsoft.IdentityModel.Protocols" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
90-
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
90+
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
9191
</dependentAssembly>
9292
<dependentAssembly>
9393
<assemblyIdentity name="Microsoft.IdentityModel.Logging" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
94-
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
94+
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
9595
</dependentAssembly>
9696
<dependentAssembly>
9797
<assemblyIdentity name="Microsoft.IdentityModel.Abstractions" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
98-
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0"/>
98+
<bindingRedirect oldVersion="0.0.0.0-8.3.0.0" newVersion="8.3.0.0"/>
9999
</dependentAssembly>
100100
<dependentAssembly>
101101
<assemblyIdentity name="Microsoft.Identity.Client" publicKeyToken="0A613F4DD989E8AE" culture="neutral"/>
102-
<bindingRedirect oldVersion="0.0.0.0-4.65.2.0" newVersion="4.65.2.0"/>
102+
<bindingRedirect oldVersion="0.0.0.0-4.66.1.0" newVersion="4.66.1.0"/>
103103
</dependentAssembly>
104104
<dependentAssembly>
105105
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="ADB9793829DDAE60" culture="neutral"/>
@@ -170,6 +170,7 @@
170170
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
171171
</dependentAssembly>
172172

173+
173174
</assemblyBinding>
174175
</runtime>
175176
<system.codedom>

0 commit comments

Comments
 (0)