Authentication 如何使用Identity Server授权Blazor WebAssembly SPA应用程序

Authentication 如何使用Identity Server授权Blazor WebAssembly SPA应用程序,authentication,identityserver4,blazor,blazor-client-side,Authentication,Identityserver4,Blazor,Blazor Client Side,我正在编写一个Blazor WebAssembly SPA技术演示应用程序,但我在身份验证方面遇到了一些问题。 我将使用Identity Server进行授权,但我找不到任何库来支持它。 我找到的所有教程都提供了使用Blazor服务器或添加ASP.net核心托管的指南,但这对于我的演示应用程序来说并没有什么意义 如果有人能帮忙,我很高兴 谢谢您2020年3月12日 要使用现有OAuth身份提供程序将OIDC添加到现有Blazor WASM应用程序,请阅读。 新的支持自动静音更新 如果您更喜欢使用

我正在编写一个Blazor WebAssembly SPA技术演示应用程序,但我在身份验证方面遇到了一些问题。 我将使用Identity Server进行授权,但我找不到任何库来支持它。 我找到的所有教程都提供了使用Blazor服务器或添加ASP.net核心托管的指南,但这对于我的演示应用程序来说并没有什么意义

如果有人能帮忙,我很高兴

谢谢您

2020年3月12日 要使用现有OAuth身份提供程序将OIDC添加到现有Blazor WASM应用程序,请阅读。
新的支持自动静音更新

如果您更喜欢使用配置文件而不是硬编码值,您可以这样设置应用程序

访问以获取完整的功能样本

  • 将你的应用升级到3.2.0预览版2
    阅读

  • 添加包Microsoft.AspNetCore.Components.WebAssembly.Authentication

  • 将AuthenticationService.js添加到index.html

...
提供将Blazor Wasm与IdentityServer一起使用的方法
阅读

2020年3月9日 目前有一些blazor OIDC库可以使用,但没有一个经过认证并实现所有功能

如果您感到好奇,我写信支持令牌静默续订,但它尚未完成,我坚持这个问题:。
这个问题在这里得到了解决。因此,必须等待或实现我自己的
WasmHttpMessageHandler


第二种方法是使用

包装。谢谢,我不知道这些项目。你帮了我很多。我只是玩了一下这些存储库,我认为HLSoft.BlazorWebAssembly.Authentication.OpenIdConnect适合我的应用程序。作者最近刚刚写了它,它将支持neswest blazor,他提供了许多expamles,一个用于完整的网站身份验证,另一个支持静默续订令牌。我认为这对于我的项目来说已经足够了——不过只是技术回顾演示。再次,非常感谢:DThanks,刚刚完成演示^^。我会检查微软的新功能。关于如何获得完整的SPA登录,而不是使用MVC脚手架,有什么建议吗?@Insight我希望这样能帮助您:
dotnet add package Microsoft.AspNetCore.Components.WebAssembly.Authentication::3.2.0-preview2.20160.5
{
  "authority": "https://myidp.com", // Uri to your IDP server
  "client_id": "myclientid", // Your client id
  "redirect_uri": "https://localhost:44333/authentication/login-callback", // Uri to the application login callback
  "post_logout_redirect_uri": "https://localhost:44333/authentication/logout-callback", // Uri to the application logout callback
  "response_type": "code", // OAuth flow response type. For `authorization_code` flow the response type is 'code'. For `implicit` flow, the response type is 'id_token token'
  "scope": "BlazorIdentityServer.ServerAPI openid profile" // list of scope your application wants
}