![](/img/trans.png)
[英]blazor webassembly windows authentication + .netcore hosted
[英]Blazor Authentication for Hosted Deployment with Multiple Webassembly Apps
我正在尝试获取多个正在运行的托管 Blazor 应用程序的样本。
文档中描述的基本设置工作正常。
现在我想添加基于 blazor webassembly 模板身份验证的个人帐户身份验证。
我让它的一部分运行,但其他部分没有工作,我什至不确定关于它的一般架构的正确方法是什么。
给定多个应用程序使用单个用户群的场景。 我是使用我的主机作为身份服务器,如下所示,还是我为所有应用程序使用第 3 方主机?
app.MapWhen(ctx => ctx.Request.Host.Port == 5001 ||
ctx.Request.Host.Equals("firstapp.com"), first =>
{
first.Use((ctx, nxt) =>
{
ctx.Request.Path = "/FirstApp" + ctx.Request.Path;
return nxt();
});
first.UseBlazorFrameworkFiles("/FirstApp");
first.UseStaticFiles();
first.UseStaticFiles("/FirstApp");
first.UseRouting();
first.UseIdentityServer();
first.UseAuthentication();
first.UseAuthorization();
first.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
endpoints.MapFallbackToFile("/FirstApp/{*path:nonfile}",
"FirstApp/index.html");
});
});
app.MapWhen(ctx => ctx.Request.Host.Port == 5002 ||
ctx.Request.Host.Equals("secondapp.com"), second =>
{
...
由于对 openid 配置 (https://localhost:5001/.well-known/openid-configuration) 的调用以及对身份服务器页面的任何调用失败,因此这没有按预期工作,例如 https://localhost :5001/身份/账号/注册
这似乎是一个路由/映射问题,尽管我不确定我必须在哪里进行更改。 有什么想法或提示吗?
我发现的另一个可能的选项是通过在 mapWhen 语句之后添加以下内容,使用第三个端口将其与客户端分开运行
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
});
这将要求客户端不要使用自己的主机进行身份验证,而是使用第三方,这会使事情变得更加复杂。 但如果这是唯一或唯一干净的解决方案,我将不得不处理它。
有很多事情需要改变:
检查这个: https://github.com/tesar-tech/MultipleBlazorAppsWithAuth
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.