gpt4 book ai didi

authentication - 限制 Azure 身份提供商

转载 作者:行者123 更新时间:2023-12-03 01:52:46 25 4
gpt4 key购买 nike

我已按照此处概述的步骤使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com