MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.25k stars 21.43k forks source link

One-time password example doesn't work #68841

Closed iamkarlson closed 3 years ago

iamkarlson commented 3 years ago

Hi, I copied technical profiles examples to my policy and it fails into the error:

Unable to cast object of type 'Web.TPEngine.Providers.OneTimePasswordProtocolProvider' to type 'Web.TPEngine.Providers.IProtocolProvider'.

Correlation ID: 94f61d59-81c7-4416-8f11-dddf21b9b557
Timestamp: 2021-01-13 11:05:30Z
AADB2C: An exception has occurred.

UserJourney used:

        <OrchestrationStep
            Order="3"
            Type="ClaimsExchange">
          <ClaimsExchanges>
            <ClaimsExchange
                Id="GenerateOtpFromEmail"
                TechnicalProfileReferenceId="GenerateOtp" />
          </ClaimsExchanges>
        </OrchestrationStep>

However, if I'm using it as a validation profile of another profile - it doesn't generate a code. Otp claim is empty.

This is an example of the UserJourney:


        <TechnicalProfile Id="GenerateOtpProfile">
          <DisplayName>Generate OTP</DisplayName>
          <Protocol
              Name="Proprietary"
              Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <InputClaims>
            <InputClaim ClaimTypeReferenceId="email" />
          </InputClaims>
          <OutputClaims>
            <OutputClaim ClaimTypeReferenceId="Otp" />
          </OutputClaims>
          <ValidationTechnicalProfiles>
            <ValidationTechnicalProfile ReferenceId="GenerateOtp" />
          </ValidationTechnicalProfiles>
        </TechnicalProfile>

.....

        <OrchestrationStep
            Order="3"
            Type="ClaimsExchange">
          <ClaimsExchanges>
            <ClaimsExchange
                Id="GenerateOtpFromEmail"
                TechnicalProfileReferenceId="GenerateOtpProfile" />
          </ClaimsExchanges>
        </OrchestrationStep>

CorrelationId for this event is 576334b2-5432-4498-9033-567617514196.

For both cases I used the same example from the docs:

    <ClaimsProvider>
      <DisplayName>One time password technical profiles</DisplayName>
      <TechnicalProfiles>
        <TechnicalProfile Id="GenerateOtp">
          <DisplayName>Generate one time password</DisplayName>
          <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.OneTimePasswordProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <Metadata>
            <Item Key="Operation">GenerateCode</Item>
            <Item Key="CodeExpirationInSeconds">1200</Item>
            <Item Key="CodeLength">6</Item>
            <Item Key="CharacterSet">0-9</Item>
            <Item Key="ReuseSameCode">true</Item>
            <Item Key="MaxNumAttempts">5</Item>
          </Metadata>
          <InputClaims>
            <InputClaim ClaimTypeReferenceId="email" PartnerClaimType="identifier" />
          </InputClaims>
          <OutputClaims>
            <OutputClaim ClaimTypeReferenceId="otp" PartnerClaimType="otpGenerated" />
          </OutputClaims>
        </TechnicalProfile>

        <TechnicalProfile Id="VerifyOtp">
          <DisplayName>Verify one time password</DisplayName>
          <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.OneTimePasswordProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <Metadata>
            <Item Key="Operation">VerifyCode</Item>
          </Metadata>
          <InputClaims>
            <InputClaim ClaimTypeReferenceId="email" PartnerClaimType="identifier" />
            <InputClaim ClaimTypeReferenceId="verificationCode" PartnerClaimType="otpToVerify" />
          </InputClaims>
        </TechnicalProfile>
       </TechnicalProfiles>
    </ClaimsProvider>

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

shashishailaj commented 3 years ago

@iamkarlson Thank you for your query. We will have this reviewed and update the thread.

amanmcse commented 3 years ago

@iamkarlson The "GenerateOtp" and "SendOtp" Technical profiles can only be used as validation technical profiles under display controls as shown below and can't be used in orchestration step under user journey.

  <DisplayControl Id="emailVerificationControl" UserInterfaceControlType="VerificationControl">
    <DisplayClaims>
      <DisplayClaim ClaimTypeReferenceId="email" Required="true" />
      <DisplayClaim ClaimTypeReferenceId="verificationCode" ControlClaimType="VerificationCode" Required="true" />
    </DisplayClaims>
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="email" />
    </OutputClaims>
    <Actions>
      <Action Id="SendCode">
        <ValidationClaimsExchange>
          <ValidationClaimsExchangeTechnicalProfile TechnicalProfileReferenceId="GenerateOtp" />
          <ValidationClaimsExchangeTechnicalProfile TechnicalProfileReferenceId="SendOtp" />
        </ValidationClaimsExchange>
      </Action>
      <Action Id="VerifyCode">
        <ValidationClaimsExchange>
          <ValidationClaimsExchangeTechnicalProfile TechnicalProfileReferenceId="VerifyOtp" />
        </ValidationClaimsExchange>
      </Action>
    </Actions>
  </DisplayControl>
</DisplayControls>

For more information, please refer to below docs: https://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-email-sendgrid https://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-email-mailjet