我正在尝试使 App Insights 工作,以便我可以使用以下方法调试我的策略:
https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-troubleshoot-custom
并基于这个项目:https : //github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/tree/master/LocalAccounts
进行了适当的修改:
<TrustFrameworkPolicy
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.microsoft.com/online/cpim/schemas/2013/06"
PolicySchemaVersion="0.3.0.0"
TenantId="B2CPruebaProteccion.onmicrosoft.com"
PolicyId="B2C_1A_PasswordReset"
PublicPolicyUri="http://B2CPruebaProteccion.onmicrosoft.com/B2C_1A_PasswordReset
UserJourneyRecorderEndpoint="urn:journeyrecorder:applicationinsights">
<BasePolicy>
<TenantId>B2CPruebaProteccion.onmicrosoft.com</TenantId>
<PolicyId>B2C_1A_TrustFrameworkExtensions</PolicyId>
</BasePolicy>
<RelyingParty>
<DefaultUserJourney ReferenceId="PasswordReset" />
<UserJourneyBehaviors>
<JourneyInsights TelemetryEngine="ApplicationInsights" InstrumentationKey="00000000-0000-0000-0000-000000000000" DeveloperMode="true" ClientEnabled="false" ServerEnabled="true" TelemetryVersion="1.0.0" />
</UserJourneyBehaviors>
<TechnicalProfile Id="PolicyProfile">
...
</TrustFrameworkPolicy>
Run Code Online (Sandbox Code Playgroud)
我的数据未显示在 App Insights 中。如何验证/修复此错误?
如何通过 Azure AD B2C 自定义策略中的 REST API 调用填充 StringCollection?
我的 Rest API 将其返回ResponseContent
class ResponseContent {
public string version;
public int status;
public string[] strings;
}
new ResponseContent
{
version = "1.0.0",
status = (int) HttpStatusCode.OK,
strings= new [] { "str1", "str2", "str3", "str4", "str5"}
},
Run Code Online (Sandbox Code Playgroud)
技术配置文件按预期执行,但当它StringCollection通过旅程记录器将显示内容填充为字符串列表时
当我尝试在自断言页面中将它们显示为下拉列表时,列表为空。
这是否可以做到这一点,如果可以的话如何实现?
这是我的声明定义,因为你看不到枚举
<ClaimType Id="strings">
<DisplayName>Strings to be populated from REST Service </DisplayName>
<DataType>stringCollection</DataType>
<AdminHelpText>blah.</AdminHelpText>
<UserHelpText>blah.</UserHelpText>
<UserInputType>DropdownSingleSelect</UserInputType>
</ClaimType>
<!-- here is the technical profile that i am using to populate …Run Code Online (Sandbox Code Playgroud) 我制作了一个程序来保存和更新数据库中的数据,我可以保存和读取数据,也可以更新,但是问题是,我无法选择"ID"作为索引,这是我的示例代码"ID"用作索引,
cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE Records SET FirstName = @firstname, LastName = @lastname, Age = @age, Address = @address, Course = @course WHERE [ID] = @id";
cmd.Parameters.AddWithValue("@id", int.Parse(label7.Text));
cmd.Parameters.AddWithValue("@firstname", textBox1.Text);
cmd.Parameters.AddWithValue("@lastname", textBox2.Text);
cmd.Parameters.AddWithValue("@age", textBox3.Text);
cmd.Parameters.AddWithValue("@address", textBox4.Text);
cmd.Parameters.AddWithValue("@course", textBox5.Text);
cmd.Connection = cn;
cn.Open();
cmd.ExecuteNonQuery();
{
MessageBox.Show("Update Success!");
cn.Close();
}
Run Code Online (Sandbox Code Playgroud)
这里是我的作品更新代码,但该指数是"firstname",
cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE Records SET FirstName = @firstname, LastName = @lastname, Age …Run Code Online (Sandbox Code Playgroud) 我正在使用 Azure AD B2C 在 AspNetCore RC2 MVC 应用程序中进行身份验证,这部分起作用,因为当我导航到需要身份验证的操作时,我会相应地重定向到 B2C 登录页面。当我成功登录时,我被正确重定向到我的应用程序页面(并且我可以看到查询参数中适当提供的 id_token 字段)。不幸的是,管道身份验证中间件似乎没有正确处理重定向查询参数,因为它立即将我重定向到登录页面。任何人都可以建议吗?
我正在使用的代码如下:
public static void UseOAuth(this IApplicationBuilder app)
{
// By default, all middleware are passive/not automatic. Making cookie middleware automatic so that it acts on all the messages.
app.UseCookieAuthentication( new CookieAuthenticationOptions{ AutomaticAuthenticate = true, CookieSecure = CookieSecureOption.Never });
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions {
ClientId = B2CAuthentication.ClientId,
ResponseType = OpenIdConnectResponseTypes.IdToken,
Authority = string.Format(CultureInfo.InvariantCulture, B2CAuthentication.AadInstance, B2CAuthentication.PortalTenant, string.Empty, string.Empty),
AuthenticationScheme = "Cookies",
Events = new OpenIdConnectEvents
{
OnAuthenticationFailed = OnAuthenticationFailed,
OnRedirectToIdentityProvider = …Run Code Online (Sandbox Code Playgroud) 从Class UserAgentApplication文档中可以找到对 STS 的引用。什么是 STS?
AcquireTokenSilent:用于从缓存中获取令牌。如果未过期,MSAL 将返回缓存的令牌。或者它会向 STS 发送请求以使用隐藏的 iframe 获取 access_token。要更新 idToken,clientId 应该作为 scopes 数组中的唯一范围传递。
我按照WingTig Games 演示代码通过 JWT 向 B2C 发送声明。如何向用户隐藏我的自我注册声明(LocalAccountSignUpWithLogonNameWithIDs 如下所示)?TechnicalProfile
我尝试UserInputType从ClaimType定义中删除该节点,但随后在用户旅程播放器中出现以下错误:
在租户“mytenant.onmicrosoft.com”的策略“B2C_1A_signup_signin_extensions”中 ID 为“LocalAccountSignUpWithLogonNameWithIDs”的技术配置文件中指定的输出声明类型“extension_my_claim”未指定 UserInputType 或 DefaultValue,也不会从 ValidationTechnicalProfile 中检索。
InputClaims因此,然后我从其中删除了我的声明,OutputClaims并TechnicalProfile删除了错误,但当时的值并未保留。
<TechnicalProfile Id="LocalAccountSignUpWithLogonNameWithIDs">
<DisplayName>User ID signup with associate and org id</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Metadata>
<Item Key="IpAddressClaimReferenceId">IpAddress</Item>
<Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
<Item Key="LocalAccountType">Username</Item>
<Item Key="LocalAccountProfile">true</Item>
<Item Key="language.button_continue">Create</Item>
</Metadata>
<CryptographicKeys>
<Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
</CryptographicKeys>
<InputClaims>
<InputClaim ClaimTypeReferenceId="signInName" />
<InputClaim ClaimTypeReferenceId="extension_my_claim" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="objectId" Required="true" /> …Run Code Online (Sandbox Code Playgroud) 根据此文档,Policy Name应该在TFP(信任框架政策)索赔中,但它出现在ACR索赔中.我开始使用Starter Pack
ID令牌瓦特/ ACR权利要求包含Policy Name
此外,在文档中进一步说,ACR是政策名称所在的位置:
在Notepad ++中,我在解码JWT时遇到问题。当我尝试Plugins -> MIME Tools -> Base64 Decode搭配使用时:
eyJleHAiOjE0NDIzNjAwMzQsIm5iZiI6MTQ0MjM1NjQzNCwidmVyIjoiMS4wIiwiaXNzIjoiaHR0cHM6Ly9sb2dpbi5taWNyb3NvZnRvbmxpbmUuY29tLzc3NTUyN2ZmLTlhMzctNDMwNy04YjNkLWNjMzExZjU4ZDkyNS92Mi4wLyIsImFjciI6ImIyY18xX3NpZ25faW5fc3RvY2siLCJzdWIiOiJOb3Qgc3VwcG9ydGVkIGN1cnJlbnRseS4gVXNlIG9pZCBjbGFpbS4iLCJhdWQiOiI5MGMwZmU2My1iY2YyLTQ0ZDUtOGZiNy1iOGJiYzBiMjlkYzYiLCJpYXQiOjE0NDIzNTY0MzQsImF1dGhfdGltZSI6MTQ0MjM1NjQzNCwiaWRwIjoiZmFjZWJvb2suY29tIn0
我得到:
要解码的所选文本(不包括EOL)的长度无效。应该是mod 4。
但是,如果使用www.base64decode.org,它可以正常工作:
{“ exp”:1442360034,“ nbf”:1442356434,“ ver”:“ 1.0”,“ iss”:“ https://login.microsoftonline.com/775527ff-9a37-4307-8b3d-cc311f58d925/v2.0/ “,” acr“:” b2c_1_sign_in_stock“,” sub“:”目前不支持。使用oid声明。“,” aud“:” 90c0fe63-bcf2-44d5-8fb7-b8bbc0b29dc6“,” iat“:1442356434,” auth_time“ :1442356434,“ idp”:“ facebook.com”}
这是为什么?我是否使用Notepad ++错误?
我使用的值来自Azure AD B2C:令牌参考。
我们在注册过程中使用 Azure AD B2C 自定义策略,并且在使用 AAD-UserWriteUsingLogonEmail 技术配置文件在 Azure AD B2C 中实际创建用户之前,我们有多个步骤(多个屏幕)。
假设我们有由以下 3 个技术配置文件定义的 3 个步骤:
第一步:
<TechnicalProfile Id="LocalAccountSignUpWithLogonEmail-FirstStep">
<DisplayName>Email signup</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Metadata>
<Item Key="IpAddressClaimReferenceId">IpAddress</Item>
<Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
<Item Key="EnforceEmailVerification">True</Item>
</Metadata>
<CryptographicKeys>
<Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
</CryptographicKeys>
<InputClaims>
<InputClaim ClaimTypeReferenceId="email" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="title" Required="true"/>
<OutputClaim ClaimTypeReferenceId="givenName" Required="true"/>
<OutputClaim ClaimTypeReferenceId="surName" Required="true"/>
<OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="Verified.Email" Required="true" />
<OutputClaim ClaimTypeReferenceId="executed-SelfAsserted-Input" DefaultValue="true" />
</OutputClaims>
<!-- no user created at this point -->
</TechnicalProfile>
Run Code Online (Sandbox Code Playgroud)
第二步 :
<TechnicalProfile …Run Code Online (Sandbox Code Playgroud) 我想知道是否有人可以为我指明一个方向或一个例子,使我获得完整的代码以得到一个总体思路?
谢谢。
更新: 我在Startup.cs中只有以下代码,并确保launchSettings.json中的windowsAutication为true。
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc(config =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
//.RequireRole(@"Departmental - Information Technology - Development") // Works
.RequireRole(@"*IT.Center of Excellence.Digital Workplace") // Error
.Build();
config.Filters.Add(new AuthorizeFilter(policy));
});
}
Run Code Online (Sandbox Code Playgroud)
我想我已启用身份验证,并尝试授权指定AD组中的用户可以在全局级别访问该应用程序。
如果我使用注释的RequireRole可以正常工作,但使用未注释的RequireRole则会给我这个错误:Win32Exception:主域和受信任域之间的信任关系失败。
堆栈的第一行显示:System.Security.Principal.NTAccount.TranslateToSids(IdentityReferenceCollection sourceAccounts,在bool someFailed外)
知道为什么吗?
从上面的更新我的理解
似乎在RequireRole中指定的组名称是电子邮件通讯组列表而不是安全组。如果我使用其他一些AD组,则可以正常工作,但会出现以下新错误:
InvalidOperationException:未指定authenticationScheme,也未找到DefaultForbidScheme。
如果我在Startup.cs的ConfigureServices中添加IIS默认authenticationScheme
services.AddAuthentication(IISDefaults.AuthenticationScheme);
Run Code Online (Sandbox Code Playgroud)
它给了我一个HTTP 403页面:该网站拒绝显示此页面
所以这是最终的代码:
services.AddAuthentication(IISDefaults.AuthenticationScheme);
Run Code Online (Sandbox Code Playgroud)
如果我理解错误,请纠正我。谢谢。
authorization asp.net-authorization asp.net-core asp.net-core-2.0 asp.net-core-mvc-2.0
azure-ad-b2c ×8
asp.net-core ×2
c# ×1
identity-experience-framework ×1
jwt ×1
notepad++ ×1
oledb ×1