为什么 asp.net 核心 3.x 使用资源所有者?

Why asp.net core 3.x use resource owner?

一些专家说 resource owner 是一种不好的身份验证做法

Scoot Brady - IdentityServer Team for example

为什么 Microsoft 在 asp.net core 3.0 中使用 resource owner 作为默认流程?

Link: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity-api-authorization?view=aspnetcore-3.1

使用resource owner安全吗?

什么时候使用?

什么时候不使用?

NO,新的Angular模板(个人认证模板)使用资源所有者流程,事实上,它使用的是Auth Code Flow + PKCE(PROOF Key for Code Exchange) ,这已经是原生应用和 SPA 的官方推荐。您可以使用 Fiddler 来跟踪身份验证请求:

授权端点的登录请求:

检查 code_challengecode_challenge_method ,这是 PKCE 的代码流。另见令牌请求:

注意 grant_type .

在代码流+PKCE 中:

  • 代替 client_secret(在正常代码流中),客户端应用程序创建一个随机值 code_verifier,并将其散列并编码为 code_challenge.

  • 授权服务器存储散列值(Code Challenge)供以后验证,并在用户通过身份验证后,使用授权码重定向回应用程序。

  • 该应用程序请求交换令牌的代码,只是它发送代码验证程序而不是固定的秘密。