authentication - 限制 Azure 身份提供商

标签 authentication azure oauth

我已按照此处概述的步骤使用 Azure Rest API/OAuth 2 流程为我的应用程序设置身份验证:

https://ahmetalpbalkan.com/blog/azure-rest-api-with-oauth2/

我已在 Azure 中创建了一个链接到 ActiveDirectory 实例的 ActiveDirectory 应用程序。

在我自己的应用程序中,我已将其配置为发布到以下 Azure OAuth 端点:

https://login.windows.net/<<MY-AD-TENANT-ID>>/oauth2/authorize?client_id=<<GUID>>&response_type=code

这一切都运行良好。我可以使用以下形式的电子邮件针对我的 ActiveDirectory 进行身份验证

someuser@<myDomain>.com

但是,我意识到我还可以使用任何有效的微软电子邮件地址进行身份验证,这显然意味着拥有有效微软电子邮件的任何人都可以获得我的应用程序的访问 token ,例如

<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7301121d171c1e26001601331b1c071e121a1f5d101c1e" rel="noreferrer noopener nofollow">[email protected]</a>

谁能告诉我如何限制身份验证仅允许我的 Active Directory 中的用户?电子邮件格式为

的用户
someuser@<myDomain>.com

我已经浏览了文档,但到目前为止还没有运气。

最佳答案

token 验证机制

这真正意味着什么:验证 token ?实际上,它可以归结为三件事:

  1. 验证其格式是否正确
  2. 验证它是否来自指定机构
  3. 验证它是否适用于当前应用

你的问题是你没有进行数字 3 验证。

您可能在验证 token 的应用程序中缺少类似的内容:

app.UseWindowsAzureActiveDirectoryBearerAuthentication(
    new WindowsAzureActiveDirectoryBearerAuthenticationOptions
    {
        Audience = ConfigurationManager.AppSettings["ida:Audience"],
        Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
    });

关于authentication - 限制 Azure 身份提供商,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32968921/

相关文章:

authentication - 是否需要 Firebase 云消息传递身份验证?

azure - 在 azure 上创建 ejbca docker 容器时出现 containerd 错误 "failed to find user by uid"

oauth - 控制台应用程序中的 Twitter OAuth

facebook - 使用 Koala 在 Facebook 中获取用户访问 token

java - 如何在同一浏览器上重新运行 Selenium 2.0 (webdriver) 测试?

java - 使用spring security成功登录后如何将对象添加到 View 中?

azure - id token 的自定义安全属性

node.js - 将 JSON 消息发送到 Azure 队列存储

ruby - 来自 ruby​​ 脚本的 OmniAuth/OAuth 身份验证

node.js - Node + express : Multiple authentication strategies according to page and user type