【发布时间】:2020-06-15 14:06:28
【问题描述】:
我有 Angular-WebApi 架构的项目,我需要添加 IS 来授权用户,但我不需要带有重定向的 mvc,我想将用户凭据从 Angular App 发送到 IS API,获取 JWT,然后使用此 JWT,用于从 Resource API 获取数据。我找不到任何例子。
【问题讨论】:
标签: asp.net-core-webapi identityserver4
我有 Angular-WebApi 架构的项目,我需要添加 IS 来授权用户,但我不需要带有重定向的 mvc,我想将用户凭据从 Angular App 发送到 IS API,获取 JWT,然后使用此 JWT,用于从 Resource API 获取数据。我找不到任何例子。
【问题讨论】:
标签: asp.net-core-webapi identityserver4
您可以将 angular-auth-oidc-client 用于您的 Angular 应用程序 你可以在这里参考示例如何做 - https://github.com/damienbod/angular-auth-oidc-client
对于 Idp 示例,Identityserver4 确实提供了 JavaScriptClient 项目下的配置示例。你可以参考这里,https://github.com/IdentityServer/IdentityServer4/tree/master/samples/Quickstarts/4_JavaScriptClient
你也可以参考我的项目,它使用了 Angular、IS4 和资源服务器 https://github.com/firdausng/testnt
【讨论】:
但我不需要带有重定向的 mvc,我想将用户凭据从 Angular App 发送到 IS API,获取 JWT,并使用此 JWT,从 Resource API 获取数据。
通常用户将被重定向到身份服务器并在登录页面中输入凭据,在 Angular 应用程序中,您可以将授权代码流与 PKCE 一起使用。
但是,如果您想在 Angular 中收集用户的凭据并将凭据发送到 IDS,您可以将 Resource Owner Password Flow 与 Identity Server 一起使用。但这是不推荐,因为 ROPC 流程需要高度的信任和用户暴露,您应该只在其他更安全的流程无法使用时才使用此流程。
【讨论】:
I can't find any examples of it.而跑题了?