diff --git a/src/Uno.Extensions.Authentication.MSAL/GlobalUsings.cs b/src/Uno.Extensions.Authentication.MSAL/GlobalUsings.cs index 09ddf622f3..1923823552 100644 --- a/src/Uno.Extensions.Authentication.MSAL/GlobalUsings.cs +++ b/src/Uno.Extensions.Authentication.MSAL/GlobalUsings.cs @@ -9,10 +9,8 @@ global using System.Threading.Tasks; global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Options; -#if UNO_EXT_MSAL global using Microsoft.Identity.Client; global using Microsoft.Identity.Client.Extensions.Msal; -#endif global using Uno.Extensions.Authentication; global using Uno.Extensions.Authentication.MSAL; global using Uno.Extensions.Configuration; diff --git a/src/Uno.Extensions.Authentication.MSAL/MsalAuthenticationBuilderExtensions.cs b/src/Uno.Extensions.Authentication.MSAL/MsalAuthenticationBuilderExtensions.cs index bc0251bfb5..e0a4f95c77 100644 --- a/src/Uno.Extensions.Authentication.MSAL/MsalAuthenticationBuilderExtensions.cs +++ b/src/Uno.Extensions.Authentication.MSAL/MsalAuthenticationBuilderExtensions.cs @@ -5,8 +5,6 @@ /// public static class MsalAuthenticationBuilderExtensions { -#if UNO_EXT_MSAL - /// /// Configures the MSAL authentication feature to use a public client application builder. /// @@ -24,6 +22,9 @@ public static IMsalAuthenticationBuilder Builder( Action build ) { +#if !UNO_EXT_MSAL + return builder; +#else if (builder is IBuilder authBuilder) { authBuilder.Settings = authBuilder.Settings with @@ -33,6 +34,7 @@ Action build } return builder; +#endif } /// @@ -52,6 +54,9 @@ public static IMsalAuthenticationBuilder Storage( Action store ) { +#if !UNO_EXT_MSAL + return builder; +#else if (builder is IBuilder authBuilder) { authBuilder.Settings = authBuilder.Settings with @@ -61,8 +66,8 @@ Action store } return builder; - } #endif + } /// /// Configures the MSAL authentication feature to be built with the specified scopes for authentication. @@ -81,6 +86,9 @@ public static IMsalAuthenticationBuilder Scopes( string[] scopes ) { +#if !UNO_EXT_MSAL + return builder; +#else if (builder is IBuilder authBuilder) { authBuilder.Settings = authBuilder.Settings with @@ -90,9 +98,9 @@ string[] scopes } return builder; +#endif } -#if UNO_EXT_MSAL /// /// Configures a public client application builder to create the MSAL authentication /// feature to use the redirect Uri provided by WebAuthenticationBroker. @@ -106,7 +114,10 @@ string[] scopes [MethodImpl(MethodImplOptions.NoInlining)] public static PublicClientApplicationBuilder WithWebRedirectUri(this PublicClientApplicationBuilder builder) { +#if !UNO_EXT_MSAL + return builder; +#else return builder.WithRedirectUri(WebAuthenticationBroker.GetCurrentApplicationCallbackUri().OriginalString); - } #endif + } } diff --git a/src/Uno.Extensions.Authentication.MSAL/MsalAuthenticationSettings.cs b/src/Uno.Extensions.Authentication.MSAL/MsalAuthenticationSettings.cs index ac510cace3..d3858c5c8c 100644 --- a/src/Uno.Extensions.Authentication.MSAL/MsalAuthenticationSettings.cs +++ b/src/Uno.Extensions.Authentication.MSAL/MsalAuthenticationSettings.cs @@ -4,10 +4,9 @@ namespace Uno.Extensions.Authentication.MSAL; internal record MsalAuthenticationSettings { -#if UNO_EXT_MSAL public Action? Build { get; init; } public Action? Store { get; init; } -#endif + public string[]? Scopes { get; init; } } diff --git a/src/Uno.Extensions.Authentication.MSAL/Uno.Extensions.Authentication.MSAL.WinUI.csproj b/src/Uno.Extensions.Authentication.MSAL/Uno.Extensions.Authentication.MSAL.WinUI.csproj index d7cf3a7d8a..0fe361c645 100644 --- a/src/Uno.Extensions.Authentication.MSAL/Uno.Extensions.Authentication.MSAL.WinUI.csproj +++ b/src/Uno.Extensions.Authentication.MSAL/Uno.Extensions.Authentication.MSAL.WinUI.csproj @@ -18,7 +18,7 @@ - + @@ -46,11 +46,9 @@ $(WarningsNotAsErrors);CS1591 - false - true $(DefineConstants);UNO_EXT_MSAL @@ -63,8 +61,8 @@ - - + + diff --git a/src/Uno.Extensions.Authentication.MSAL/build/Package.targets b/src/Uno.Extensions.Authentication.MSAL/build/Package.targets index ca89baa368..791b408420 100644 --- a/src/Uno.Extensions.Authentication.MSAL/build/Package.targets +++ b/src/Uno.Extensions.Authentication.MSAL/build/Package.targets @@ -4,7 +4,6 @@ - true $(DefineConstants);UNO_EXT_MSAL diff --git a/testing/TestHarness/TestHarness/Ext/Authentication/Msal/MsalAuthenticationHostInit.cs b/testing/TestHarness/TestHarness/Ext/Authentication/Msal/MsalAuthenticationHostInit.cs index a76d7bae67..f7d207d249 100644 --- a/testing/TestHarness/TestHarness/Ext/Authentication/Msal/MsalAuthenticationHostInit.cs +++ b/testing/TestHarness/TestHarness/Ext/Authentication/Msal/MsalAuthenticationHostInit.cs @@ -15,7 +15,6 @@ protected override IHostBuilder Custom(IHostBuilder builder) auth.AddMsal(msal => msal .Scopes(new[] { "Tasks.Read", "User.Read", "Tasks.ReadWrite" }) -#if UNO_EXT_MSAL .Builder(msalBuilder => msalBuilder .WithClientId("161a9fb5-3b16-487a-81a2-ac45dcc0ad3b") @@ -25,7 +24,6 @@ protected override IHostBuilder Custom(IHostBuilder builder) //{ // msalBuilder = msalBuilder.WithIosKeychainSecurityGroup(settings.KeychainSecurityGroup); //} -#endif ) ); } diff --git a/testing/TestHarness/TestHarness/Ext/Authentication/Msal/MsalAuthenticationMultiHostInit.cs b/testing/TestHarness/TestHarness/Ext/Authentication/Msal/MsalAuthenticationMultiHostInit.cs index 33e20cfaed..bbadf78080 100644 --- a/testing/TestHarness/TestHarness/Ext/Authentication/Msal/MsalAuthenticationMultiHostInit.cs +++ b/testing/TestHarness/TestHarness/Ext/Authentication/Msal/MsalAuthenticationMultiHostInit.cs @@ -103,7 +103,6 @@ protected override IHostBuilder Custom(IHostBuilder builder) } return default; }), name: "CustomService") -#if UNO_EXT_MSAL .AddMsal(msal => msal .Scopes(new[] { "Tasks.Read", "User.Read", "Tasks.ReadWrite" }) @@ -118,7 +117,6 @@ protected override IHostBuilder Custom(IHostBuilder builder) //} , name: "MsalCode") .AddMsal(name: "MsalConfig") -#endif ); }