Skip to content

Commit 1623ac6

Browse files
authored
Revert UseDefaultRedirectUri (#601)
- Revert UseDefaultRedirectUri back to localhost - This change broke netfx browser auth because it was returning `https://login.microsoftonline.com/common/oauth2/nativeclient` which is not configured as a redirect on the client app - we either need to revert this or consider updating the client app
1 parent 0a792bf commit 1623ac6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/Authentication/AzureArtifacts.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static class AzureArtifacts
2222
private const string LegacyClientId = "872cd9fa-d31f-45e0-9eab-6e460a02d1f1";
2323

2424
private const string MacOSXRedirectUri = "msauth.com.microsoft.azureartifacts.credentialprovider://auth";
25+
private const string LinuxRedirectUri = "https://login.microsoftonline.com/oauth2/nativeclient";
2526

2627
public static PublicClientApplicationBuilder CreateDefaultBuilder(Uri authority)
2728
{
@@ -30,19 +31,19 @@ public static PublicClientApplicationBuilder CreateDefaultBuilder(Uri authority)
3031

3132
var builder = PublicClientApplicationBuilder.Create(prod ? AzureArtifacts.ClientId : AzureArtifacts.LegacyClientId)
3233
.WithAuthority(authority)
33-
.WithDefaultRedirectUri();
34+
.WithRedirectUri("http://localhost");
3435

3536
return builder;
3637
}
3738

38-
public static PublicClientApplicationBuilder WithMacOSXRedirectUri(this PublicClientApplicationBuilder builder)
39+
public static PublicClientApplicationBuilder WithBrokerRedirectUri(this PublicClientApplicationBuilder builder)
3940
{
40-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
41+
return true switch
4142
{
42-
return builder;
43-
}
44-
45-
return builder.WithRedirectUri(MacOSXRedirectUri);
43+
_ when RuntimeInformation.IsOSPlatform(OSPlatform.OSX) => builder.WithRedirectUri(MacOSXRedirectUri),
44+
_ when RuntimeInformation.IsOSPlatform(OSPlatform.Linux) => builder.WithRedirectUri(LinuxRedirectUri),
45+
_ => builder // Windows or other platforms use default
46+
};
4647
}
4748

4849
public static PublicClientApplicationBuilder WithBroker(this PublicClientApplicationBuilder builder, bool enableBroker, IntPtr? parentWindowHandle, ILogger logger)
@@ -56,7 +57,7 @@ public static PublicClientApplicationBuilder WithBroker(this PublicClientApplica
5657
logger.LogTrace(Resources.MsalUsingBroker);
5758

5859
return builder
59-
.WithMacOSXRedirectUri()
60+
.WithBrokerRedirectUri()
6061
.WithBroker(
6162
new BrokerOptions(BrokerOptions.OperatingSystems.Windows | BrokerOptions.OperatingSystems.OSX | BrokerOptions.OperatingSystems.Linux)
6263
{

0 commit comments

Comments
 (0)