Skip to content

Add ClaimData for AuthenticationStateData and fix overtrimming #56878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

halter73
Copy link
Member

This PR is a follow up to #55821 which added the AuthenticationStateProvider implementations from the .NET 8 Blazor web project templates to the runtime. You can opt into using these by adding the new services as follows.

// Server Program.cs
builder.Services.AddRazorComponents()
    .AddInteractiveWebAssemblyComponents()
    .AddAuthenticationStateSerialization();
// Client Program.cs
builder.Services.AddAuthenticationStateDeserialization();

These services rely on JSON serializing and deserializing the newly added AuthenticationStateData type which previously contained a Claims property of type IList<KeyValuePair<string, string>>. After API review feedback in #52769, we've decided to update AuthenticationStateData.Claims to be an IList<ClaimData>.

This PR also fixes #56207 which was caused by the overtrimming AuthenticationStateData.Claims and updates the ServerRenderedAuthenticationStateTest and DefaultAuthenticationStateSerializationOptionsTest to test published trimmed WebAssembly static assets.

As part of this, I refactored the common logic of most tests that currently use static assets published to the "trimmed-or-threading" to use the new TrimmingServerFixture. However, I wonder if we should go further and make BasicTestAppServerSiteFixture use trimmed static assets by default when TestTrimmedOrMultithreadingApps is configured.

Fixes #52769
Fixes #56207

@halter73 halter73 requested a review from a team as a code owner July 18, 2024 17:47
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Jul 18, 2024
@halter73 halter73 requested a review from javiercn July 18, 2024 17:47
namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;

// REVIEW: Should this be merged into BasicTestAppServerSiteFixture? Is there any case where we wouldn't
// want to trim BasicTestAppServerSiteFixture tests when TestTrimmedOrMultithreadingApps is true?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dotnet/aspnet-blazor-eng I'm curious what everyone thinks about this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that if other tests don't break, we could enable it, but I suspect we wanted to have this isolated. I believe in the past we would test all the apps with trimming during release. I don't know if/when that changed, but I'm ok if we bring that back.

@halter73 halter73 requested a review from amcasey July 18, 2024 18:08
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Product change LGTM. I'll let the stakeholders figure out the test infra changes.

@halter73 halter73 enabled auto-merge (squash) July 19, 2024 18:43
@halter73 halter73 merged commit a8f5c7e into main Jul 19, 2024
26 checks passed
@halter73 halter73 deleted the halter73/56207 branch July 19, 2024 19:38
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0-preview7 milestone Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build in AuthenticationStateProvider breaks after trimming Build in AuthenticationStateProviders from Blazor Web templates
3 participants