【问题标题】:Do I need to validate the UserInfo of AuthenticationResult like we need for the token?我需要像我们需要令牌一样验证 AuthenticationResult 的 UserInfo 吗?
【发布时间】:2019-07-21 00:19:21
【问题描述】:

所以我使用ADAL 库来实现我的应用程序的 Azure 目录单点登录。 documentation

我将 { "scope", "openid"} 添加到请求 url,以便返回 id_token。然后我检索用户的唯一 ID 以在数据库中查找。

AuthenticationContext ac = new AuthenticationContext(MicrosoftAuthBaseURL);

ClientCredential clcred = new ClientCredential(MicrosoftAppId, MicrosoftAppSecret);
AuthenticationResult acResult = ac.AcquireTokenByAuthorizationCodeAsync(code, new Uri(RedirectURI), clcred).Result;

SignInUser(acResult.UserInfo.UniqueId);

我知道验证访问令牌或 id 令牌是一种很好的做法,但在我的情况下,这些令牌都没有直接使用。我只是检索/使用UniqueId 字段。所以我的问题是,我还需要在这里做任何验证吗?我应该验证什么,我可以在库中利用任何内置的验证方法吗?我不喜欢手动做。

【问题讨论】:

    标签: asp.net jwt azure-active-directory single-sign-on adal


    【解决方案1】:

    在这种情况下,我会说验证不是强制性的,因为您会收到来自 Azure AD 的直接响应的令牌。 如果有人可以拦截并替换令牌,那么他们也可以替换您的应用程序检索到的签名密钥。 这意味着他们可以伪造任何他们想要的代币。

    【讨论】:

      猜你喜欢
      • 2019-08-10
      • 2015-12-25
      • 1970-01-01
      • 1970-01-01
      • 2019-04-20
      • 2012-02-23
      • 1970-01-01
      • 2011-05-04
      • 2023-03-12
      相关资源
      最近更新 更多