我正在尝试 Azure AD B2C,并且我已通过 Azure 门户添加了 Google 和 Microsoft 身份提供商。
当我尝试使用 Microsoft 或 Google IP 登录时,我总是在 OnAuthenticationFailed-Handler 中收到以下错误消息:
AADB2C99002: 用户不存在。请先注册,然后才能登录。
但是,当我使用 Azure B2C 提供的“本地帐户登录”时,一切正常。我的配置中是否缺少某些内容?
以下代码片段显示了我的 OWIN 配置。
private void ConfigureAuthentication(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
OpenIdConnectAuthenticationOptions options = new OpenIdConnectAuthenticationOptions
{
// These are standard OpenID Connect parameters, with values pulled from web.config
ClientId = clientId,
RedirectUri = redirectUri,
PostLogoutRedirectUri = redirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = OnAuthenticationFailed,
RedirectToIdentityProvider = OnRedirectToIdentityProvider,
AuthorizationCodeReceived = OnAuthorizationCodeReceived,
SecurityTokenValidated = context => …Run Code Online (Sandbox Code Playgroud) 我们尝试集成的客户端将 ADFS 作为其 IDP。客户尝试使用 Azure AD B2C 作为其 IDP。
错误在于 Azure AD B2C 尝试直接连接到不向公众开放的 SAML 端点,因此失败。
有没有办法将其 Federation.xml 文件上传到 Azure AD B2C,以便它不会尝试连接到 URL?
我有 1 个 SPA 应用程序,它使用另一个 WebApi。(ASP.NET Core)两者都在 Azure 中运行,我能够使用 OAuth 2.0 隐式流程对 Azure AD B2C 进行用户身份验证
现在我问自己如何控制单个用户的权限。(删除、读取等)我必须处理索赔吗?我是否必须利用服务器端的图形 API 来检查用户是否具有特定权限?我可以使用范围吗?在哪里可以设置 User <--> Scope 关系?
我发现了几个关于 SO 的问题,但我不知道应该如何以正确的方式完成它?我目前的理解是,我向身份验证提供商询问某些范围,然后我将获得具有此范围的令牌,然后可以通过 API 进行检查。但是我如何管理哪些用户可以请求哪些范围呢?
我真的很难理解 OAuth2 和权限。希望有人能在这里帮助我。
上传注册政策时出现此错误。
验证失败:在租户“titanidaasdevb2c.onmicrosoft.com”的策略“B2C_1A_SIGNUP_WEB_SP”中发现 1 个验证错误。在策略“B2C_1A_SignUp_Web_SP”的技术配置文件“AAD-UserWriteUsingLogonEmail”中需要DisableStrongPassword 以用于自定义密码复杂性或旧密码限制弱自定义正则表达式。在 PersistedClaim "passwordPolicies" 中添加 "DisablePasswordExpiration, DisableStrongPassword"
请指导我。
我决定使用Microsoft.Graph.NET SDK,而不是使用带有手动 HTTP 请求的旧 Azure Graph API。
问题是当我尝试使用一些电子邮件创建新用户时,例如 areller@gmail.com
var req = _client.Users.Request();
var userRes = req.AddAsync(new User()
{
AccountEnabled = true,
DisplayName = user.Email,
MailNickname = user.GivenName,
GivenName = user.GivenName,
Surname = user.SurName,
UserPrincipalName = user.Email,
PasswordProfile = new PasswordProfile()
{
Password = user.Password,
ForceChangePasswordNextSignIn = true
},
PasswordPolicies = "DisablePasswordExpiration, DisableStrongPassword",
Country = user.Country,
City = user.City,
PostalCode = user.ZipCode
}).Result;
Run Code Online (Sandbox Code Playgroud)
我收到一个异常,显示“属性 userPrincipalName 无效”

当我将租户用作域的电子邮件时,我只能创建用户,例如,areller@mytenant.onmicrosoft.com
但这不是我需要的。我需要能够以编程方式创建实际的外部用户。
使用 Azure Graph API 它可以工作 有没有办法让它与 Microsoft Graph API …
我想在 Azure AD B2C 中创建自定义策略。我在starterpack中找不到这样的例子。
我检查了这篇文章Azure AD B2C 注册页面链接(未登录),如果我理解正确,则没有可用于现有自定义signup_signin策略的 URL 直接出现在注册页面中。创建“注册 v2”流程是可行的,但我需要一个自定义流程,并且从构建中复制代码并将其放置到LocalAccounts入门包中的示例中是行不通的。
这是UserJourney从“Sign up v2”流程下载的代码
<UserJourney Id="B2CSignUp_V2">
<OrchestrationSteps>
<OrchestrationStep Order="1" Type="ClaimsProviderSelection" ContentDefinitionReferenceId="api.idpselections.signup">
<ClaimsProviderSelections>
<ClaimsProviderSelection TargetClaimsExchangeId="SignUpWithLogonEmailExchange" />
</ClaimsProviderSelections>
</OrchestrationStep>
</OrchestrationSteps>
</UserJourney>
Run Code Online (Sandbox Code Playgroud)
我尝试将OrchestrationStep入门包中的 1 和 2 替换为此处的 1 和 2,但它不起作用。
我使用 Azure AD B2C 作为身份验证门户。我试图通过发送查询参数 prompt=select_account 来保证 Google+ 始终转到选择帐户页面。但是我很难达到这种行为。
从谷歌文档https://developers.google.com/identity/protocols/OpenIDConnect,可以接收此参数,这将保证用户转到选择帐户。
在遵循文档https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow 时,似乎提示没有到达谷歌,假设最后认证。
我正在尝试使用 Passport.js 和 Azure Active Directory B2C 和 OpenID Connect 策略为我的 Node.js Web 应用程序实施面向客户的身份验证。
我已经按照官方 GitHub 页面的 README 说明研究了官方示例应用程序的源代码,但它们似乎不完整和/或已过时,正如在线各个线程所同意的那样。
在将网络上的各种提示拼凑起来后,我已经越过许多桥梁,但由于以下错误而陷入僵局:
cannot get AAD Federation metadata from endpoint you specified.
AAD 身份验证需要大量配置,因此我将注意一些重要值:
policyName:这是b2c_1_signin,就像我在 Azure 门户中配置的一样。identityMetadata:我正在使用特定于租户的 v2.0 端点。我添加?p=b2c_1_signin了注入策略名称。responseType: id_tokenredirectUrl:这是我在 Azure 中配置的本地主机和端口。allowHttpForRedirectUrl设置为true。(这适用于非生产环境。)isB2C: truenode.js passport.js azure-ad-b2c azure-ad-msal passport-azure-ad
我需要在我有权访问的 AAD B2C 租户中获取用户详细信息:
az ad user show --id 0cbb4fd6-7091-44fb-ab5e-d2bd9c366f59
Run Code Online (Sandbox Code Playgroud)
这找不到用户,因为我登录到我的组织常规 AAD 租户。B2C 租户没有订阅,他们链接到主要租户,这意味着我不能这样做
az login -t myb2ctenant.onmicrosoft.com
Run Code Online (Sandbox Code Playgroud)
在门户中工作并不方便,我想在 CLI 中执行我的例程。我怎样才能做到这一点?
command-line-interface azure azure-active-directory azure-cli azure-ad-b2c
当我使用 Microsoft Graph API 从 Azure AD B2C 获取用户时,用户注册的电子邮件地址没有出现在返回的 JSON 中。尽管 SO 中的帖子建议电子邮件地址应存在于邮件(otherMails 或 signInNames)以外的其他字段中,但接收到的 JSON 不包含任何具有预期电子邮件地址的字段。这是我为测试用户运行的请求(敏感数据被屏蔽):
GET https://graph.microsoft.com/v1.0/users/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Authorization: Bearer xxxxxxxxx
Content-Type: application/json
Run Code Online (Sandbox Code Playgroud)
响应中的 JSON 是:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"businessPhones": [],
"displayName": "unknown",
"givenName": "some",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "user",
"userPrincipalName": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@xxxxx.onmicrosoft.com",
"id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Run Code Online (Sandbox Code Playgroud)
尽管如此,当我在 Azure AD B2C 中看到用户时,电子邮件地址显示在用户列表页面的“用户名”列下:
当我查看用户的个人资料时,电子邮件地址也会显示在“用户主体名称”字段下:
电子邮件来自哪里,我如何使用 MS Graph API 获取它?
azure-active-directory azure-ad-graph-api azure-ad-b2c microsoft-graph-api
azure-ad-b2c ×10
azure ×5
.net ×1
azure-cli ×1
c# ×1
google-plus ×1
node.js ×1
oauth-2.0 ×1
passport.js ×1