没有 identi Identity 的 Blazor 应用程序中的 RevalidatingServerAuthenticationStateProvider

ado*_*lot 6 cookies asp.net-identity blazor blazor-server-side

我正在尝试使用cookie 身份验证而不使用 ASP.NET Core Identity来构建 Blazor 服务器端应用程序。我确实按照上面的示例成功获得了身份验证。在我的应用程序中,我跳过了services.AddIdentity应用程序,到目前为止应用程序工作没有问题,我能够登录、注销、确定用户角色等。

我不太确定我理解的是RevalidatingServerAuthenticationStateProvider类及其服务,services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<AppUser>>();

Blazor 应用程序是否需要此服务才能继续与客户端通信,或者它只是安全屏障?
只要 cookie 没有过期,我就可以让客户端保持登录状态。
如果我需要RevalidatingServerAuthenticationStateProvider服务,我如何确认用户通过后有效 AuthenticationState?(查看索赔或其他内容)。

小智 2

这里,

受保护覆盖​​ TimeSpan RevalidationInterval => TimeSpan.FromMinutes(30);

意味着,每隔 30 分钟,此机制将调用ValidateAuthenticationStateAsync来检查当前身份验证是否有效。