2017-10-05 72 views
0

我已經爲基於來自Active Directory B2C custom policy starter pack for social and local accounts的例子社會和本地帳戶創建自定義策略後停止工作。我已經啓用了微軟和谷歌的登錄功能,並測試了兩者都可以工作,我也啓用了使用本地帳戶登錄。Azure的AD B2C本地帳戶密碼的幾個小時

我看到的問題是本地帳戶。我可以創建一個,密碼工作幾個小時(不確定確切的時間),然後開始給出一個通用的「無效的用戶名或密碼」。錯誤。當我爲同一個用戶輸入錯誤的密碼時,我收到一條不同的消息「您的密碼不正確」(這對應於相關的日誌條目)。

我已啓用應用程序見解,只能找到以下例外。

任何關於如何清除這兩個錯誤的幫助將會很好。

""Statebag"": { ""Complex-CLMS"": {}, ""ValidationRequest"": { ""ContentType"": ""Unspecified"", ""Created"": ""2017-10-04T19:17:49.2510644Z"", ""Key"": ""ValidationRequest"", ""Persistent"": true, ""Value"": ""client_id=307&resource=cf87&username=user%domain.com&[email protected]!123&grant_type=password&scope=openid&nca=1;1;login-NonInteractive;False"" }, ""ValidationResponse"": { ""ContentType"": ""Json"", ""Created"": ""2017-10-04T19:17:49.2510644Z"", ""Key"": ""ValidationResponse"", ""Persistent"": true, ""Value"": ""{\""error\"":\""invalid_grant\"",\""error_description\"":\""AADSTS65001: The user or administrator has not consented to use the application with ID '307' named 'IdentityExperienceFramework'. Send an interactive authorization request for this user and resource.\\r\\nTrace ID: 7c4\\r\\nCorrelation ID: 3cc\\r\\nTimestamp: 2017-10-04 19:17:49Z\"",\""error_codes\"":[65001],\""timestamp\"":\""2017-10-04 19:17:49Z\"",\""trace_id\"":\""7c4\"",\""correlation_id\"":\""3cc\""};1;login-NonInteractive;False"" }, ""ComplexItems"": ""_MachineEventQ, REPRM, TCTX, M_EXCP"" } 這裏是第二個例外

""Key"": ""Exception"", ""Value"": { ""Kind"": ""Handled"", ""HResult"": ""80131500"", ""Message"": ""The technical Profile with id \""AAD-UserWriteUsingLogonEmail\"" in Policy id \""B2C_1A_signup_signin of Tenant id \""xxx.onmicrosoft.com\"" requires that an error be raised if a claims principal record already exists for storing claims. A claims principal of type \""User\"" with identifier claim type id \""signInNames.emailAddress\"" does already exist."", ""Data"": { ""IsPolicySpecificError"": true, ""TenantId"": ""xxx.onmicrosoft.com"", ""PolicyId"": ""B2C_1A_signup_signin"", ""TechnicalProfile.Id"": ""AAD-UserWriteUsingLogonEmail"", ""ClaimsPrincipal.IdentifierClaim.ClaimTypeId"": ""signInNames.emailAddress"", ""ClaimsPrincipal.PrincipalType"": ""User"", ""CreateClaimsPrincipalIfItDoesNotExist"": ""True"", ""RaiseErrorIfClaimsPrincipalAlreadyExists"": ""True"", ""RaiseErrorIfClaimsPrincipalDoesNotExist"": ""False"" } }

這裏是TrustFrameworkExtensions.xml文件的內容。它和例子之間的唯一區別是,我使用2個提供商而不是1

<?xml version="1.0" encoding="utf-8" ?> 
<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="xxx.onmicrosoft.com" 
    PolicyId="B2C_1A_TrustFrameworkExtensions" 
    PublicPolicyUri="http://xxx.onmicrosoft.com/B2C_1A_TrustFrameworkExtensions"> 

    <BasePolicy> 
    <TenantId>xxx.onmicrosoft.com</TenantId> 
    <PolicyId>B2C_1A_TrustFrameworkBase</PolicyId> 
    </BasePolicy> 
    <BuildingBlocks> 

    </BuildingBlocks> 

    <ClaimsProviders> 

    <ClaimsProvider> 
     <DisplayName>Local Account SignIn</DisplayName> 
     <TechnicalProfiles> 
     <TechnicalProfile Id="login-NonInteractive"> 
      <Metadata> 
      <Item Key="client_id">307</Item> 
      <Item Key="IdTokenAudience">cf8</Item> 
      </Metadata> 
      <InputClaims> 
      <InputClaim ClaimTypeReferenceId="client_id" DefaultValue="307" /> 
      <InputClaim ClaimTypeReferenceId="resource_id" PartnerClaimType="resource" DefaultValue="cf8" /> 
      </InputClaims> 
     </TechnicalProfile> 
     </TechnicalProfiles> 
    </ClaimsProvider> 

    <ClaimsProvider> 
     <Domain>Employee SignIn with Azure AD</Domain> 
     <DisplayName>Employee Login</DisplayName> 
     <TechnicalProfiles> 
      <TechnicalProfile Id="AzureADProfile"> 
       <DisplayName>Employee Login</DisplayName> 
       <Description>Login with your GP account</Description> 
       <Protocol Name="OpenIdConnect"/> 
       <OutputTokenFormat>JWT</OutputTokenFormat> 
       <Metadata> 
        <Item Key="METADATA">https://login.windows.net/yyy.onmicrosoft.com/.well-known/openid-configuration</Item> 
        <Item Key="ProviderName">https://sts.windows.net/7de/</Item> 
        <Item Key="client_id">f19</Item> 
        <Item Key="IdTokenAudience">f19</Item> 
        <Item Key="response_types">id_token</Item> 
        <Item Key="UsePolicyInRedirectUri">false</Item> 
       </Metadata> 
       <CryptographicKeys> 
        <Key Id="client_secret" StorageReferenceId="B2C_1A_AzureADAppSecret"/> 
       </CryptographicKeys> 
       <OutputClaims> 
        <OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="oid"/> 
        <OutputClaim ClaimTypeReferenceId="tenantId" PartnerClaimType="tid"/> 
        <OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="given_name" /> 
        <OutputClaim ClaimTypeReferenceId="surName" PartnerClaimType="family_name" /> 
        <OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="name" /> 
        <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="contosoAuthentication" /> 
        <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="AzureADContoso" /> 
       </OutputClaims> 
       <OutputClaimsTransformations> 
        <OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName"/> 
        <OutputClaimsTransformation ReferenceId="CreateUserPrincipalName"/> 
        <OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId"/> 
        <OutputClaimsTransformation ReferenceId="CreateSubjectClaimFromAlternativeSecurityId"/> 
       </OutputClaimsTransformations> 
       <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop"/> 
      </TechnicalProfile> 
     </TechnicalProfiles> 
    </ClaimsProvider> 

    <ClaimsProvider> 
     <Domain>google.com</Domain> 
     <DisplayName>Google</DisplayName> 
     <TechnicalProfiles> 
     <TechnicalProfile Id="Google-OAUTH"> 
      <DisplayName>Employee Login</DisplayName> 
      <Protocol Name="OAuth2" /> 
      <Metadata> 
      <Item Key="ProviderName">google</Item> 
      <Item Key="authorization_endpoint">https://accounts.google.com/o/oauth2/auth</Item> 
      <Item Key="AccessTokenEndpoint">https://accounts.google.com/o/oauth2/token</Item> 
      <Item Key="ClaimsEndpoint">https://www.googleapis.com/oauth2/v1/userinfo</Item> 
      <Item Key="scope">email</Item> 
      <Item Key="HttpBinding">POST</Item> 
      <Item Key="UsePolicyInRedirectUri">0</Item> 
      <Item Key="client_id">zzz.apps.googleusercontent.com</Item> 
      </Metadata> 
      <CryptographicKeys> 
      <Key Id="client_secret" StorageReferenceId="B2C_1A_GoogleSecret" /> 
      </CryptographicKeys> 
      <OutputClaims> 
      <OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="id" /> 
      <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="email" /> 
      <OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="given_name" /> 
      <OutputClaim ClaimTypeReferenceId="surname" PartnerClaimType="family_name" /> 
      <OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="name" /> 
      <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="google.com" /> 
      <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" /> 
      </OutputClaims> 
      <OutputClaimsTransformations> 
      <OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName" /> 
      <OutputClaimsTransformation ReferenceId="CreateUserPrincipalName" /> 
      <OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId" /> 
      <OutputClaimsTransformation ReferenceId="CreateSubjectClaimFromAlternativeSecurityId" /> 
      </OutputClaimsTransformations> 
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin" /> 
      <ErrorHandlers> 
      <ErrorHandler> 
       <ErrorResponseFormat>json</ErrorResponseFormat> 
       <ResponseMatch>$[?(@@.error == 'invalid_grant')]</ResponseMatch> 
       <Action>Reauthenticate</Action> 
       <!--In case of authorization code used error, we don't want the user to select his account again.--> 
       <!--AdditionalRequestParameters Key="prompt">select_account</AdditionalRequestParameters--> 
      </ErrorHandler> 
      </ErrorHandlers> 
     </TechnicalProfile> 
     </TechnicalProfiles> 
    </ClaimsProvider> 

    </ClaimsProviders> 



    <UserJourneys> 
     <UserJourney Id="SignUpOrSignInUsingAzureAD"> 
     <OrchestrationSteps> 

     <OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin"> 
      <ClaimsProviderSelections>    
      <ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninEmailExchange" /> 
      <ClaimsProviderSelection TargetClaimsExchangeId="GoogleExchange" /> 
      <ClaimsProviderSelection TargetClaimsExchangeId="AzureADExchange" /> 
      </ClaimsProviderSelections> 
      <ClaimsExchanges> 
      <ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" /> 
      </ClaimsExchanges> 

     </OrchestrationStep> 

     <!-- Check if the user has selected to sign in using one of the social providers --> 
     <OrchestrationStep Order="2" Type="ClaimsExchange"> 
      <Preconditions> 
      <Precondition Type="ClaimsExist" ExecuteActionsIf="true"> 
       <Value>objectId</Value> 
       <Action>SkipThisOrchestrationStep</Action> 
      </Precondition> 
      </Preconditions> 
      <ClaimsExchanges> 
      <ClaimsExchange Id="GoogleExchange" TechnicalProfileReferenceId="Google-OAUTH" /> 
      <ClaimsExchange Id="AzureADExchange" TechnicalProfileReferenceId="AzureADProfile" /> 
      <ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="LocalAccountSignUpWithLogonEmail" /> 
      </ClaimsExchanges> 
     </OrchestrationStep> 

     <!-- For social IDP authentication, attempt to find the user account in the directory. --> 
     <OrchestrationStep Order="3" Type="ClaimsExchange"> 
      <Preconditions> 
      <Precondition Type="ClaimEquals" ExecuteActionsIf="true"> 
       <Value>authenticationSource</Value> 
       <Value>localAccountAuthentication</Value> 
       <Action>SkipThisOrchestrationStep</Action> 
      </Precondition> 
      </Preconditions> 
      <ClaimsExchanges> 
      <ClaimsExchange Id="AADUserReadUsingAlternativeSecurityId" TechnicalProfileReferenceId="AAD-UserReadUsingAlternativeSecurityId-NoError" /> 
      </ClaimsExchanges> 
     </OrchestrationStep> 

     <!-- Show self-asserted page only if the directory does not have the user account already (i.e. we do not have an objectId). 
      This can only happen when authentication happened using a social IDP. If local account was created or authentication done 
      using ESTS in step 2, then an user account must exist in the directory by this time. --> 
     <OrchestrationStep Order="4" Type="ClaimsExchange"> 
      <Preconditions> 
      <Precondition Type="ClaimsExist" ExecuteActionsIf="true"> 
       <Value>objectId</Value> 
       <Action>SkipThisOrchestrationStep</Action> 
      </Precondition> 
      </Preconditions> 
      <ClaimsExchanges> 
      <ClaimsExchange Id="SelfAsserted-Social" TechnicalProfileReferenceId="SelfAsserted-Social" /> 
      </ClaimsExchanges> 
     </OrchestrationStep> 

     <!-- This step reads any user attributes that we may not have received when authenticating using ESTS so they can be sent 
      in the token. --> 
     <OrchestrationStep Order="5" Type="ClaimsExchange"> 
      <Preconditions> 
      <Precondition Type="ClaimEquals" ExecuteActionsIf="true"> 
       <Value>authenticationSource</Value> 
       <Value>socialIdpAuthentication</Value> 
       <Action>SkipThisOrchestrationStep</Action> 
      </Precondition> 
      </Preconditions> 
      <ClaimsExchanges> 
      <ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" /> 
      </ClaimsExchanges> 
     </OrchestrationStep> 
     <!-- The previous step (SelfAsserted-Social) could have been skipped if there were no attributes to collect 
      from the user. So, in that case, create the user in the directory if one does not already exist 
      (verified using objectId which would be set from the last step if account was created in the directory. --> 
     <OrchestrationStep Order="6" Type="ClaimsExchange"> 
      <Preconditions> 
      <Precondition Type="ClaimsExist" ExecuteActionsIf="true"> 
       <Value>objectId</Value> 
       <Action>SkipThisOrchestrationStep</Action> 
      </Precondition> 
      </Preconditions> 
      <ClaimsExchanges> 
      <ClaimsExchange Id="AADUserWrite" TechnicalProfileReferenceId="AAD-UserWriteUsingAlternativeSecurityId" /> 
      </ClaimsExchanges> 
     </OrchestrationStep> 

     <OrchestrationStep Order="7" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" /> 

     </OrchestrationSteps> 
     <ClientDefinition ReferenceId="DefaultWeb" /> 
    </UserJourney> 
    </UserJourneys> 

</TrustFrameworkPolicy> 
+0

您是否截斷了客戶端ID和受衆羣體問題,還是那些真正的價值? (即307和cf8) –

+0

我已經截斷,始終如一我相信... –

回答

0

此錯誤

The user or administrator has not consented to use the application with ID '307' named 'IdentityExperienceFramework'. 

你的AZURE AD葉片內壓在這個應用程序的授予權限按鈕內天青

第二個例外

它看起來像你試圖再次寫入用戶主體和元數據中它具有RaiseErrorIfUserPrinci palExists設爲後悔

但奇怪的是沒有真正幫助我理解爲什麼幾個小時後,您的密碼不工作

最好的辦法是在這裏複製的策略,我們可以嘗試告訴你爲什麼你想一寫的,而不是讀

+0

我的策略與示例之間唯一真正的區別在於trustframeworextensions.xml文件中,我已將其複製到問題中。 –

+0

我發誓我之前按下了授權按鈕,但是當我按下它時,密碼錯誤消失了,但第二個異常仍然存在。 –

+0

您是否可以添加技術參數文件AAD-UserWriteUsingLogonEmail,它位於底部,儘管在線示例有這條線 true將true改爲false將防止錯誤被記錄 – user1197563

0

由於實際錯誤可能是由於在該目錄的政策和應用程序配置的組合,我會解釋爲什麼這些應用程序都需要進行設置這樣,什麼可能是問題。我希望即使我對根本原因的猜測是錯誤的,這個解釋也會讓你進一步調試問題。

認爲,需要爲用戶驗證密碼的應用程序。由於應用程序無法訪問密碼,因此其中一種方法是使用用戶的ID和密碼向login.microsoftonline.com發送身份驗證請求,並查看令牌是否已成功發佈。

然而,當該應用程序發送一個請求,它必須指定一些資源,而且還必須有代表用戶的權限訪問該資源。常見的解決方法是管理員代表所有用戶授予權限(即同意)。

IEF使用相同的型號。您的策略有兩個應用程序,一個用作客戶端,代表用戶代表該資源獲取令牌。如果您按照「Custom Policies Get Started Page」中的說明操作,則ProxyIdentityExperienceFramework是客戶端,IdentityExperienceFramework是資源。按照這些說明,只有ProxyIdentityExperienceFramework可以代表用戶獲得IdentityExperienceFramework的令牌,而不是反之。

根據您在日誌中的錯誤信息,它似乎,你可能已經扭轉了客戶端的識別碼與資源:

用戶或管理員不同意使用該應用程序 與ID爲「307」命名爲「IdentityExperienceFramework

也就是說,所謂的IdentityExperienceFramework客戶端不能訪問得到的令牌。

因此,您需要檢查Azure AD門戶,該應用程序有權訪問哪個應用程序並更新客戶端ID和資源ID。

第二個異常可能確實是由設計決定的,它只是告訴您在目錄中創建的用戶已經存在。這通常發生在註冊時,並且根據您的策略設置,它通常會向用戶顯示一條錯誤消息,指示該帳戶已存在,並且應該登錄。