Skip to content

Commit

Permalink
Merge pull request #2198 from unoplatform/dev/nr/4xauth
Browse files Browse the repository at this point in the history
fix: Configuration information not passed to Authentication providers by name
  • Loading branch information
nickrandolph authored Mar 14, 2024
2 parents 38495ed + 02a1a72 commit ce7aa2a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/Uno.Extensions.Configuration/ConfigBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,11 @@ public static IConfigBuilder Section<TSettingsOptions>(
{
if (configSection is null)
{
if (configurationSection is { Length: > 0 })
if (configurationSection is not { Length: > 0 })
{
configSection = ctx => ctx.Configuration.GetSection(configurationSection);
}
else
{
configSection = ctx => ctx.Configuration.GetSection(typeof(TSettingsOptions).Name);
configurationSection = typeof(TSettingsOptions).Name;
}
configSection = ctx => ctx.Configuration.GetSection(configurationSection);
}

static string? FilePath(HostBuilderContext hctx)
Expand Down Expand Up @@ -160,7 +157,7 @@ public static IConfigBuilder Section<TSettingsOptions>(
}

var section = configSection(ctx);
services.ConfigureAsWritable<TSettingsOptions>(section, configPath);
services.ConfigureAsWritable<TSettingsOptions>(section, configPath, configurationSection);
}

).AsConfigBuilder();
Expand Down
5 changes: 3 additions & 2 deletions testing/TestHarness/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
<PackageVersion Include="Microsoft.Toolkit.Uwp.UI" Version="7.1.2" />
<PackageVersion Include="Microsoft.UI.Xaml" Version="2.8.5" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2365.46" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.5.240311000" />
<PackageVersion Include="Microsoft.Windows.Compatibility" Version="5.0.0" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
<PackageVersion Include="Refit" Version="6.3.2" />
<PackageVersion Include="Refit.HttpClientFactory" Version="6.3.2" />
<PackageVersion Include="SkiaSharp" Version="2.88.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protected override IHostBuilder Custom(IHostBuilder builder)
return builder
.UseAuthentication(auth =>
auth
.AddWeb<IWebAuthenticationTestEndpoint>(name: "WebSettings")) // name defines not only the name of the provider but also the section in the appsettings file
.AddWeb<IWebAuthenticationTestEndpoint>(name: "WebSettings")
.AddWeb<IWebAuthenticationTestEndpoint>(name: "WebSettings2")) // name defines not only the name of the provider but also the section in the appsettings file

.ConfigureServices(services =>
services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"WebSettings": {
"LoginStartUri": "https://localhost:7193/webauth/Login/Facebook?redirect_uri=oidc-auth://",
"LogoutStartUri": "https://localhost:7193/webauth/Logout/Facebook"
},
"WebSettings2": {
"LoginStartUri": "https://localhost:7193/webauth/Login/Facebook?redirect_uri=oidc-auth://&setting=2",
"LogoutStartUri": "https://localhost:7193/webauth/Logout/Facebook&setting=2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<DefaultLanguage>en</DefaultLanguage>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<!--<WindowsPackageType>None</WindowsPackageType>-->
<EnableMsixTooling>false</EnableMsixTooling>
<EnableMsixTooling>true</EnableMsixTooling>
</PropertyGroup>

<PropertyGroup><!-- Bundles the WinAppSDK binaries (Uncomment for unpackaged builds) -->
Expand Down Expand Up @@ -41,6 +41,7 @@
<PackageReference Include="IdentityModel.OidcClient" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Microsoft.Identity.Client" />
<PackageReference Include="Microsoft.Web.WebView2"/>
<PackageReference Include="Microsoft.WindowsAppSDK" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" />
<PackageReference Include="Refit" />
Expand Down Expand Up @@ -94,4 +95,33 @@

<Import Project="..\..\..\src\Uno.Extensions.Core.Generators\buildTransitive\Uno.Extensions.Core.props" />
<Import Project="..\TestHarness.Shared\TestHarness.Shared.projitems" Label="Shared" Condition="Exists('..\TestHarness.Shared\TestHarness.Shared.projitems')" />

<!--
This is a temporary workaround to avoid error "NETSDK1152: Found multiple publish output files with the same relative path:"
for Microsoft.Web.WebView2.Core.dll, with one coming from MsixContent and the other from the Microsoft.Web.Webview2 Nuget package.
If both are present, we only keep the one from the NuGet package. See https://github.com/unoplatform/uno/issues/14555.
-->
<Target Name="ResolveWebView2CoreDuplicates1" BeforeTargets="_ComputeResolvedFilesToPublishTypes" AfterTargets="ComputeFilesToPublish">
<Message Importance="high" Text ="Applying workaround to resolve Microsoft.Web.WebView2.Core.dll duplication in package (1)" />
<ItemGroup>
<_WebView2CoreFilesToExclude Include="@(ResolvedFileToPublish)" Condition="'%(Filename)' == 'Microsoft.Web.WebView2.Core'"/>
</ItemGroup>
<ItemGroup Condition="'@(_WebView2CoreFilesToExclude->Count())' &gt; 1">
<_WebView2CoreFilesToExclude Remove="@(_WebView2CoreFilesToExclude)" Condition="$([System.String]::Copy(%(FullPath)).Contains('.nuget'))"/>
<ResolvedFileToPublish Remove="@(_WebView2CoreFilesToExclude)" />
</ItemGroup>
<Message Importance="high" Text ="Removed: @(_WebView2CoreFilesToExclude)" />
</Target>

<Target Name="ResolveWebView2CoreDuplicates2" BeforeTargets="_ComputeAppxPackagePayload" AfterTargets="GetPackagingOutputs">
<Message Importance="high" Text ="Applying workaround to resolve Microsoft.Web.WebView2.Core.dll duplication in package (2)" />
<ItemGroup >
<_WebView2CoreOutputsToExclude Include="@(PackagingOutputs)" Condition="'%(Filename)' == 'Microsoft.Web.WebView2.Core'"/>
</ItemGroup>
<ItemGroup Condition="'@(_WebView2CoreOutputsToExclude->Count())' &gt; 1">
<_WebView2CoreOutputsToExclude Remove="@(_WebView2CoreOutputsToExclude)" Condition="$([System.String]::Copy(%(FullPath)).Contains('.nuget'))"/>
<PackagingOutputs Remove="@(_WebView2CoreOutputsToExclude)" />
</ItemGroup>
<Message Importance="high" Text ="Removed: @(_WebView2CoreOutputsToExclude)" />
</Target>
</Project>

0 comments on commit ce7aa2a

Please sign in to comment.