Skip to content

Commit afa8d56

Browse files
authored
Serialize all claims for auth state serialization (#531)
1 parent b9ff89a commit afa8d56

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

9.0/BlazorWebAppEntra/BlazorWebAppEntra/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
var builder = WebApplication.CreateBuilder(args);
99

1010
// Add services to the container.
11+
// Remove or set 'SerializeAllClaims' to 'false' if you only want to
12+
// serialize name and role claims for CSR.
1113
builder.Services.AddRazorComponents()
1214
.AddInteractiveServerComponents()
1315
.AddInteractiveWebAssemblyComponents()
14-
.AddAuthenticationStateSerialization();
16+
.AddAuthenticationStateSerialization(options => options.SerializeAllClaims = true);
1517

1618
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
1719
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))

9.0/BlazorWebAppEntraBff/BlazorWebAppEntra/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727

2828
builder.Services.AddCascadingAuthenticationState();
2929

30+
// Remove or set 'SerializeAllClaims' to 'false' if you only want to
31+
// serialize name and role claims for CSR.
3032
builder.Services.AddRazorComponents()
3133
.AddInteractiveServerComponents()
3234
.AddMicrosoftIdentityConsentHandler()
3335
.AddInteractiveWebAssemblyComponents()
34-
.AddAuthenticationStateSerialization();
36+
.AddAuthenticationStateSerialization(options => options.SerializeAllClaims = true);
3537

3638
builder.Services.AddHttpForwarderWithServiceDiscovery();
3739
builder.Services.AddHttpContextAccessor();

9.0/BlazorWebAppOidc/BlazorWebAppOidc/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@
149149

150150
builder.Services.AddCascadingAuthenticationState();
151151

152+
// Remove or set 'SerializeAllClaims' to 'false' if you only want to
153+
// serialize name and role claims for CSR.
152154
builder.Services.AddRazorComponents()
153155
.AddInteractiveServerComponents()
154156
.AddInteractiveWebAssemblyComponents()
155-
.AddAuthenticationStateSerialization();
157+
.AddAuthenticationStateSerialization(options => options.SerializeAllClaims = true);
156158

157159
builder.Services.AddScoped<IWeatherForecaster, ServerWeatherForecaster>();
158160

9.0/BlazorWebAppOidcBff/BlazorWebAppOidc/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,12 @@
154154

155155
builder.Services.AddCascadingAuthenticationState();
156156

157+
// Remove or set 'SerializeAllClaims' to 'false' if you only want to
158+
// serialize name and role claims for CSR.
157159
builder.Services.AddRazorComponents()
158160
.AddInteractiveServerComponents()
159161
.AddInteractiveWebAssemblyComponents()
160-
.AddAuthenticationStateSerialization();
162+
.AddAuthenticationStateSerialization(options => options.SerializeAllClaims = true);
161163

162164
builder.Services.AddHttpForwarderWithServiceDiscovery();
163165
builder.Services.AddHttpContextAccessor();

0 commit comments

Comments
 (0)