需要身份验证 Azure 广告客户端密码吗?

Autentication Azure ad Client Secret is necessary?

我有以下疑问,我有一个基于 Microsoft 身份验证的项目,前端 angular 使用 msal,后端使用 passport-azure-ad。 我的问题如下,是否需要使用客户端密码?

当我们在 OpenID Connect 中使用授权码流或混合流时,客户端将授权码交换为访问令牌。在此步骤中,客户端必须向服务器验证自己的身份。对客户端进行身份验证的一种方法是使用客户端密码。

Web 应用程序需要客户端密码 可以将 client_secret 安全地存储在服务器上 side.All 机密客户端可以选择使用客户端密码或证书凭据和护照 azure 广告库专为服务器端网络应用程序中的身份验证流程而设计。

Note:ClientID and Client Secrets are passed to AAD by MSAL, and if you are using a confidential client (like: WebApp, WebAPI or Daemon/Service) that runs on Azure PaaS Service, or any other secured servers, only the clientID gets exposed by MSAL but not the client secret, as the client secret is passed only in the backend (server side) to AAD and never directly exposed and requires proper authentication.

msal client apps

如果您的应用是原生应用 (spa),则不需要客户端密码

Public 客户端,包括本机应用程序和单页应用程序,在兑换授权码时不得使用机密或证书,因为 client_secret 无法可靠地存储在设备或网页上,并且如果密钥暴露在客户端,则该密钥可能容易受到攻击..

参考: v2-oauth2-auth-code-flow-Client secret