Skip to content

Commit

Permalink
use different IUserClaimsPrincipalFactory in services, this avoids th…
Browse files Browse the repository at this point in the history
…e roles being put inside the user principal and consequently in the identity cookie, because they are quite big and unnecessary in our permission-based code (#2022)
  • Loading branch information
Masterjun3 authored Oct 26, 2024
1 parent 500f758 commit 97e2860
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions TASVideos/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public static IServiceCollection AddServices(this IServiceCollection services)
public static IServiceCollection AddIdentity(this IServiceCollection services, IHostEnvironment env)
{
services.Configure<PasswordHasherOptions>(options => options.IterationCount = 720_000);
services.AddScoped<IUserClaimsPrincipalFactory<User>, UserClaimsPrincipalFactory<User>>(); // the default would use UserClaimsPrincipalFactory<User, Role>, but like this we prevent it putting roles in the principal and thus in the identity cookie
services.AddIdentity<User, Role>(config =>
{
config.SignIn.RequireConfirmedEmail = env.IsProduction() || env.IsStaging();
Expand Down

0 comments on commit 97e2860

Please sign in to comment.