首页 > 解决方案 > 经过一定时间后的 MFA 提示

问题描述

我们在生产中使用 B2C 自定义策略,并要求在经过一定时间(20 分钟 + 取决于应用程序)后,无论用户登录哪个服务,都会提示用户再次使用 MFA 登录。我们的一位开发人员表示,我们可以使用 max_age 查询字符串参数来实现这一点,我想在这里发帖看看是否有人有使用 Azure B2C 自定义策略的经验,或者可以推荐其他解决方案?我找到了这个链接,但没有太多其他https://github.com/MicrosoftDocs/azure-docs/issues/51307

我们目前在我们的政策中使用以下 MFA 方法,稍作修改以删除电子邮件验证,因为我们不需要这样做:https ://github.com/azure-ad-b2c/samples/tree/master/policies/mfa-邮件或者电话

编辑

嗨@Jas 我有时间研究解决方案,但有一个问题希望你能回答。

我们已经能够在会话中而不是在扩展属性中存储用户最后一次执行 MFA 的时间。起初,我们无法在第一次登录后运行 OutputClaimsTransformation“CompareTimetoLastMFATime”,但我们发现在下面的代码中显示的技术配置文件“MFAReadStoredMFATime”中删除了。您能否告诉我们为什么包含 SM-MFA 会阻止索赔转换在后续登录时运行?我们看到第 16 步在日志中运行,但是没有声明转换,也没有输出 CompareTimetoLastMFATime,因此用户总是跳过 MFA。

<OrchestrationStep Order="16" Type="ClaimsExchange">
                    <ClaimsExchanges>
                        <ClaimsExchange Id="MFAReadStoredMFATime" TechnicalProfileReferenceId="MFAReadStoredMFATime" />
                    </ClaimsExchanges>
                </OrchestrationStep>

<OrchestrationStep Order="17" Type="ClaimsExchange">
          <Preconditions>
            <!--Sample: If the preferred MFA method is not 'phone' skip this orchestration step-->
            <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
              <Value>extension_mfaByPhoneOrEmail</Value>
              <Value>phone</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
            <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
              <Value>mfa_required</Value>
              <Value>true</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
            <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
              <Value>MFADoneByFedIdp</Value>
              <Value>True</Value>
              <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
            <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
                            <Value>isLastMFATimeGreaterThanWindow</Value>
                            <Value>False</Value>
                            <Action>SkipThisOrchestrationStep</Action>
                        </Precondition>
          </Preconditions>
          <ClaimsExchanges>
            <ClaimsExchange Id="PhoneFactor-Verify" TechnicalProfileReferenceId="PhoneFactor-InputOrVerify" />
          </ClaimsExchanges>
        </OrchestrationStep>
<TechnicalProfile Id="MFAReadStoredMFATime">
          <DisplayName>Fixt the session username issue</DisplayName>
          <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.ClaimsTransformationProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <InputClaims>
          <InputClaim ClaimTypeReferenceId="LastMFATime" DefaultValue="2018-10-01T15:00:00.0000000Z" />
          </InputClaims>
          <OutputClaims>
          <OutputClaim ClaimTypeReferenceId="isLastMFATimeGreaterThanWindow" />
          </OutputClaims>
            <OutputClaimsTransformations>
                        <OutputClaimsTransformation ReferenceId="CompareTimetoLastMFATime" />
                    </OutputClaimsTransformations>
        </TechnicalProfile>
<ClaimsTransformation Id="CompareTimetoLastMFATime" TransformationMethod="DateTimeComparison">
                <InputClaims>
                    <InputClaim ClaimTypeReferenceId="LastMFATime" TransformationClaimType="firstDateTime" />
                    <InputClaim ClaimTypeReferenceId="systemDateTime" TransformationClaimType="secondDateTime" />
                </InputClaims>
                <InputParameters>
                    <InputParameter Id="operator" DataType="string" Value="earlier than" />
                    <InputParameter Id="timeSpanInSeconds" DataType="int" Value="100" />
                </InputParameters>
                <OutputClaims>
                    <OutputClaim ClaimTypeReferenceId="isLastMFATimeGreaterThanWindow" TransformationClaimType="result" />
                </OutputClaims>
            </ClaimsTransformation>

标签: azure-ad-b2cazure-ad-b2c-custom-policy

解决方案


这里有一个示例可以在超过一定时间后强制执行 mfa。 https://github.com/azure-ad-b2c/samples/tree/master/policies/mfa-absolute-timeout-and-ip-change-trigger


推荐阅读