Azure B2C 自定义策略本地帐户 KMSI 无法让我保持登录状态

Azure B2C Custom Policies local account KMSI doesn't keep me signed in

我实施了 example - all worked as expect to this point - and then I followed the instructions 中的步骤以启用 KMSI。

在测试 Identity Experience Framework->Custom Policies->B2C_1A_signup_signin ->运行 时,我可以在登录时打开复选框 "Keep me signed in"。但是,我关闭了这个 window(或为此保持打开状态),再次 运行 自定义策略并要求我再次登录("Keep me signed in" 未选中)。

我已经三次检查了教程和示例中的更改,看不出有任何区别(除了 example 我没有 LoadURI 和 RecoveryURI。

我注意到我没有按照 ContentDefinitions and only followed the instructions in enable KMSI 进行更改,因为我认为这不是教程中的要求。

请给我一些指导可能是错误的。感谢您的帮助

您测试 KMSI 功能的方法有误。

如果您 "Run the custom policy again",它总是会要求您重新输入您的凭据,这是设计使然。

您应该按照 Test your policy 的步骤进行操作。

您可以在首次登录后关闭window。 然后按照步骤 4、5 和 6:

  1. Go back to the Azure portal. Go to the policy page, and then select Copy to copy the sign-in URL.
  2. In the browser address bar, remove the &prompt=login query string parameter, which forces the user to enter their credentials on that request.
  3. In the browser, click Go. Now Azure AD B2C will issue an access token without prompting you to sign-in again.


更新:

您不需要替换 SignUpOrSignin.xmlTrustFrameworkExtensions.xml。仅参考我的修改:

将以下代码片段添加到 TrustFrameworkExtensions.xml 中的 BuildingBlocks 元素中。

<ContentDefinitions>
    <ContentDefinition Id="api.signuporsignin">
        <LoadUri>~/tenant/default/unified.cshtml</LoadUri>
        <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
        <DataUri>urn:com:microsoft:aad:b2c:elements:unifiedssp:1.1.0</DataUri>
        <Metadata>
          <Item Key="DisplayName">Signin and Signup</Item>
        </Metadata>
      </ContentDefinition>
  </ContentDefinitions>

然后添加以下节点作为元素的子节点。它必须紧跟在 <DefaultUserJourney ReferenceId="User journey Id" />.

之后
<UserJourneyBehaviors>
  <SingleSignOn Scope="Tenant" KeepAliveInDays="30" />
  <SessionExpiryType>Absolute</SessionExpiryType>
  <SessionExpiryInSeconds>1200</SessionExpiryInSeconds>
</UserJourneyBehaviors>

这些就是需要进行的所有更改。

您不需要删除文件中的 &prompt=login。请看我上面的截图。复制登录后URL,会是这样:

https://**.b2clogin.com/**.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1A_SignUpOrSignIn&client_id=**&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=id_token&prompt=login

只需删除 URL 末尾的 &prompt=login 并在新的 window 中访问它。