分享方式:


在 Azure Active Directory B2C 自訂原則中定義 OAuth1 技術設定檔

注意

在 Azure Active Directory B2C 中,自訂原則的主要用途為處理複雜的案例。 在大部分情況下,我們建議使用內建的使用者流程。 如果您尚未執行此操作,請於在 Active Directory B2C 中開始使用自訂原則中,了解自訂原則入門套件。

Azure Active Directory B2C (Azure AD B2C) 可提供對 OAuth 1.0 通訊協定識別提供者的支援。 本文會說明技術設定檔的詳細規格,其可和支援此標準化通訊協定的宣告提供者互動。 有了 OAuth1 技術設定檔,您就能與以 OAuth1 為基礎的識別提供者 (例如 Twitter) 同盟。 與識別提供者同盟,可讓使用者使用其現有的社交或企業身分識別登入。

通訊協定

Protocol 元素的 Name 屬性必須設定為 OAuth1。 例如,Twitter-OAUTH1 技術設定檔的通訊協定是

<TechnicalProfile Id="Twitter-OAUTH1">
  <DisplayName>Twitter</DisplayName>
  <Protocol Name="OAuth1" />
  ...

輸入宣告

InputClaimsInputClaimsTransformations 元素是空的或不存在。

輸出宣告

OutputClaims 元素包含 OAuth1 識別提供者傳回的宣告清單。 您可能需要將原則中定義的宣告名稱對應至識別提供者中定義的名稱。 只要設定 DefaultValue 屬性,您也可以包含識別提供者未傳回的宣告。

OutputClaimsTransformations 元素可能含有 OutputClaimsTransformation 的集合,用於修改輸出宣告或產生新的輸出宣告。

下列範例顯示 Twitter 識別提供者傳回的宣告:

  • 對應至 issuerUserId 宣告的 user_id 宣告。
  • 對應至 displayName 宣告的 screen_name 宣告。
  • email 宣告沒有名稱對應。

技術設定檔也會傳回識別提供者未傳回的宣告:

  • 包含識別提供者名稱的 identityProvider 宣告。
  • 具有預設值 authenticationSource 宣告。
<OutputClaims>
  <OutputClaim ClaimTypeReferenceId="issuerUserId" PartnerClaimType="user_id" />
  <OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="screen_name" />
  <OutputClaim ClaimTypeReferenceId="email" />
  <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="twitter.com" />
  <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" />
</OutputClaims>

中繼資料

屬性 必要 說明
client_id Yes 識別提供者的應用程式識別碼。
ProviderName No 識別提供者的名稱。
request_token_endpoint Yes 依據 RFC 5849 的要求權杖端點 URL。
authorization_endpoint Yes 依據 RFC 5849 的授權端點 URL。
access_token_endpoint Yes 依據 RFC 5849 的權杖端點 URL。
ClaimsEndpoint No 使用者資訊端點的 URL。
ClaimsResponseFormat No 宣告回應格式。

密碼編譯金鑰

CryptographicKeys 元素包含下列屬性:

屬性 必要 描述
client_secret Yes 識別提供者應用程式的用戶端密碼。

重新導向 URI

在設定識別提供者的重新導向 URI 時,請輸入 https://{tenant-name}.b2clogin.com/{tenant-name}.onmicrosoft.com/{policy-id}/oauth1/authresp。 請務必將 {tenant-name} 取代為您的租用戶名稱 (例如 contosob2c.onmicrosoft.com),並將 {policy-id} 取代為原則的識別碼 (例如 b2c_1a_policy)。 重新導向 URI 必須全部小寫。 為所有使用識別提供者登入的原則新增重新導向 URL。

範例: