【问题标题】:Will MSAL be able to maintain a token cache and refreshes tokens for you when they are close to expire in case of Custom REST API secured by Azure AD在 Azure AD 保护的自定义 REST API 的情况下,MSAL 是否能够维护令牌缓存并在令牌即将过期时为您刷新令牌
【发布时间】:2021-02-27 09:57:13
【问题描述】:

基于在 https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/MSAL.NET-supports-multiple-application-architectures-and-multiple-platforms#msalnet-is-about-acquiring-tokens-not-protecting-an-api 中提到的 MSAL (Azure AD) 的文档详细信息

我正在研究 POC:ASP.NET Web App 访问受 Azure AD 保护的自定义 REST API。

上面提到的链接说MSAL.NET (Microsoft Authentication Library for .NET) enables developers of .NET applications to acquire tokens in order to call secured Web APIs. These Web APIs can be the Microsoft Graph, other Microsoft APIS, 3rd party Web APIs, or your own Web API.

根据上述定义,最好假设 MSAL 将帮助维护令牌缓存并在令牌即将过期时为您刷新令牌,以防自定义 REST API 也是如此。

任何人都可以通过提供进一步的指导来帮助我吗?

【问题讨论】:

    标签: asp.net azure-active-directory msal


    【解决方案1】:

    MSAL 和 Azure AD 不会对 MS Graph API 令牌进行特殊处理(使用范围短名称的能力除外)。 只要刷新方式仍然有效,它就可以刷新任何令牌。 在隐式授权的情况下(由 MSAL.js 1.x 使用),用户必须在浏览器中具有活动的 AAD 会话。 在大多数其他情况下,您使用刷新令牌来获取新令牌;只要刷新令牌仍然有效,即使访问令牌过期,您也可以获得新令牌。

    【讨论】:

    • 感谢@juunas 的回复。它对我理解 MSAL 概念有很大帮助。
    猜你喜欢
    • 2019-08-25
    • 2018-01-03
    • 2023-01-17
    • 2019-08-24
    • 2015-02-13
    • 2020-01-25
    • 2018-04-11
    • 1970-01-01
    • 2019-11-17
    相关资源
    最近更新 更多