Skip to content

Commit

Permalink
Fix Blazor context manager config issue (#4081)
Browse files Browse the repository at this point in the history
* Update version to 8.2.5

* #4075 Fix configuration issue

* #4075 Add services, don't just try

* Use count instead of any

* #4075 Don't flow identity back from client to server

* Update to target version 8.2.5

* Update release notes
  • Loading branch information
rockfordlhotka committed Jul 7, 2024
1 parent 9dfe3fc commit 1418457
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Csla.Blazor.WebAssembly" Version="8.1.1-R24051003" />
<PackageReference Include="Csla.Blazor.WebAssembly" Version="8.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

builder.Services.AddCsla(o => o
.AddBlazorWebAssembly(o => o.SyncContextWithServer = true)
.Security(o => o.FlowSecurityPrincipalFromClient = true)
.Security(o => o.FlowSecurityPrincipalFromClient = false)
.DataPortal(o => o.ClientSideDataPortal(o => o
.UseHttpProxy(o => o.DataPortalUrl = "/api/DataPortal"))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<ProjectReference Include="..\DataAccess.EF\DataAccess.EF.csproj" />
<ProjectReference Include="..\DataAccess.Mock\DataAccess.Mock.csproj" />
<ProjectReference Include="..\DataAccess\DataAccess.csproj" />
<PackageReference Include="Csla.AspNetCore" Version="8.1.1-R24051003" />
<PackageReference Include="Csla.Blazor" Version="8.1.1-R24051003" />
<PackageReference Include="Csla.AspNetCore" Version="8.2.5" />
<PackageReference Include="Csla.Blazor" Version="8.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
builder.Services.AddCsla(o => o
.AddAspNetCore()
.AddServerSideBlazor(o => o.UseInMemoryApplicationContextManager = false)
.Security(so => so.FlowSecurityPrincipalFromClient = true)
.Security(so => so.FlowSecurityPrincipalFromClient = false)
.DataPortal(dpo => dpo
.AddServerSideDataPortal()
.ClientSideDataPortal(co => co
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Csla" Version="8.1.1-R24051003" />
<PackageReference Include="Csla" Version="8.2.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Csla" Version="8.1.1-R24051003" />
<PackageReference Include="Csla" Version="8.2.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Csla" Version="8.1.1-R24051003" />
<PackageReference Include="Csla" Version="8.2.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Csla" Version="8.1.1-R24051003" />
<PackageReference Include="Csla" Version="8.2.5" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Csla.Blazor.WebAssembly.Configuration;

namespace Csla.Configuration
Expand Down Expand Up @@ -40,11 +39,11 @@ public static CslaOptions AddBlazorWebAssembly(this CslaOptions config, Action<B
options?.Invoke(blazorOptions);

config.Services.AddScoped((_) => blazorOptions);
config.Services.TryAddTransient(typeof(ViewModel<>), typeof(ViewModel<>));
config.Services.TryAddScoped<IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>();
config.Services.TryAddScoped<IAuthorizationHandler, CslaPermissionsHandler>();
config.Services.TryAddScoped(typeof(Csla.Core.IContextManager), typeof(Csla.Blazor.WebAssembly.ApplicationContextManager));
config.Services.TryAddScoped(typeof(AuthenticationStateProvider), typeof(Csla.Blazor.Authentication.CslaAuthenticationStateProvider));
config.Services.AddTransient(typeof(ViewModel<>), typeof(ViewModel<>));
config.Services.AddScoped<IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>();
config.Services.AddScoped<IAuthorizationHandler, CslaPermissionsHandler>();
config.Services.AddScoped(typeof(Csla.Core.IContextManager), typeof(Csla.Blazor.WebAssembly.ApplicationContextManager));
config.Services.AddScoped(typeof(AuthenticationStateProvider), typeof(Csla.Blazor.Authentication.CslaAuthenticationStateProvider));

// use Blazor state management
config.Services.AddScoped(typeof(ISessionManager), blazorOptions.SessionManagerType);
Expand Down
3 changes: 2 additions & 1 deletion Source/Csla/Configuration/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// </copyright>
// <summary>Implement extension methods for base .NET configuration</summary>
//-----------------------------------------------------------------------
using Csla.Core;
using Csla.DataPortalClient;
using Csla.Runtime;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -70,7 +71,7 @@ private static void RegisterContextManager(IServiceCollection services, Type con
services.AddScoped<Core.ApplicationContextAccessor>();
services.TryAddScoped(typeof(Core.IContextManagerLocal), typeof(Core.ApplicationContextManagerAsyncLocal));

var managerInit = services.Any(i => i.ServiceType.Equals(contextManagerType));
var managerInit = services.Count(static i => i.ServiceType.Equals(typeof(IContextManager))) > 0;
if (managerInit) return;

if (contextManagerType != null)
Expand Down
11 changes: 10 additions & 1 deletion releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ CSLA 8 is a substantial update to CSLA .NET, adding support for .NET 8 and other

## CSLA .NET version 8.2.5 release

Updates NuGet package to include latest code changes.
* [#4075](https://github.com/MarimerLLC/csla/issues/4075) Fix configuration issue with Blazor DI services

### Change List

* https://github.com/MarimerLLC/csla/compare/v8.2.4...v8.2.5

### Contributors

* @jmpotvin
* @rockfordlhotka

## CSLA .NET version 8.2.4 release

Expand Down

0 comments on commit 1418457

Please sign in to comment.