> ## Documentation Index
> Fetch the complete documentation index at: https://translations.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Auth0 が IDプロバイダーである場合の SAML 属性マッピングの例を示します。

# Auth0 を IdP/SAML Add-on として使用する場合の SAML 属性のマッピング

Auth0 が <Tooltip tip="IDプロバイダー（IdP）：デジタル ID を保存および管理するサービス。" cta="用語集を表示" href="/ja/docs/glossary?term=IdP">IdP</Tooltip> の場合、Auth0 の SAML2 アドオンを使用してユーザー属性をマッピングできます。属性の設定が誤っていると、エラーが発生することがあります。たとえば、ユーザーは username と password を正しく入力しているのに、<Tooltip tip="Auth0 Dashboard: サービスを設定するための Auth0 の主要製品。" cta="用語集を表示" href="/ja/docs/glossary?term=Auth0+Dashboard">Auth0 Dashboard</Tooltip> のログにはログイン成功イベントが記録されているにもかかわらず、アプリケーションにサインインできない場合があります。また、アプリケーションで 名前 や メールアドレス などのユーザー情報が取得できないこともあります。

<div id="use-cases">
  ## ユースケース
</div>

以下のユーザープロファイルは、次のシナリオで使用する例です。

```javascript lines theme={null}
//サンプル IdP ユーザープロファイル
{
   "created_at": "2021-06-21T13:26:08.579Z",
   "email": "testuser@example.com",
...
   "fav_genre": "fiction",
   "user_metadata": {
       "fav_streaming_service": "hulu"
   }
...
}
```

<div id="no-mappings-object">
  #### mappings オブジェクトなし
</div>

SAML2 アドオンを使用すると、空の mappings オブジェクトがデフォルトで生成されます。

この例では、`fav_genre` と `user_metadata.fav_streaming_service` は未定義ですが、カスタマイズして、Auth0 によって生成される <Tooltip tip="Security Assertion Markup Language（SAML）: パスワードなしで 2 者間の認証情報の交換を可能にする標準化プロトコル。" cta="用語集を表示" href="/ja/docs/glossary?term=SAML">SAML</Tooltip> レスポンスにマッピングできます。

以下の例では、`"fav_genre": "fiction"` は `fiction` の値を持つ [http://schemas.auth0.com/fav\_genre](http://schemas.auth0.com/fav_food) 属性として SAML レスポンスにマッピングされますが、`"user_metadata": {"fav_streaming_service": "hulu"}` は SAML レスポンスにはまったく含まれません。

IdP が送信する最終的な SAML レスポンス:

```xml lines theme={null}
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_e30cb5f29249a82846eb" InResponseTo="_e33996d83f953ce46225185b3a1c0ad8" Version="2.0" IssueInstant="2021-11-03T21:34:42.493Z" Destination="https://example-dev-tenant.us.auth0.com/login/callback">
...
       <saml:AttributeStatement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
           <saml:Attribute Name="http://schemas.auth0.com/fav_genre" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
               <saml:AttributeValue xsi:type="xs:string">
                   fiction
               </saml:AttributeValue>
           </saml:Attribute>
...
       </saml:AttributeStatement>
   </saml:Assertion>
</samlp:Response>
```

<div id="standard-mappings-example">
  #### 標準マッピングの例
</div>

前の例では、mappings オブジェクト をカスタマイズしなかったため、SAML レスポンス には値 `"fiction"` を持つ [http://schemas.auth0.com/fav\_genre](http://schemas.auth0.com/fav_food) 属性が含まれていました。

次に、それに対応するように、SAML2 アドオン settings の mappings オブジェクト で属性をマッピングします。

これを行うと、SAML レスポンス 内の `"fiction"` 値は同じままですが、属性名はデフォルトの [http://schemas.auth0.com/fav\_fiction](http://schemas.auth0.com/fav_food) から [http://schemas.auth0.com/books](http://schemas.auth0.com/dinner) に変更されていることがわかります。

SAML2 アドオン の mappings オブジェクト の設定:

```json lines theme={null}
"mappings": {
   "fav_genre": "http://schemas.auth0.com/books"
 }
```

このマッピングにより、次のようなレスポンスが返されます。

```xml lines theme={null}
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_e30cb5f29249a82846eb" InResponseTo="_e33996d83f953ce46225185b3a1c0ad8" Version="2.0" IssueInstant="2021-11-03T21:34:42.493Z" Destination="https://example-dev-tenant.us.auth0.com/login/callback">
...
       <saml:AttributeStatement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
           <saml:Attribute Name="http://schemas.auth0.com/books" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
               <saml:AttributeValue xsi:type="xs:string">
                   fiction
               </saml:AttributeValue>
           </saml:Attribute>
...
       </saml:AttributeStatement>
   </saml:Assertion>
</samlp:Response>
```

<div id="mapping-the-same-value-to-multiple-attributes">
  #### 同じ値を複数の属性にマッピングする
</div>

同じ値を SAML レスポンス の複数の属性にマッピングする必要がある場合があります。

この場合、ユーザープロファイル内の同じ値を SAML レスポンス の複数の属性にマッピングできます。

SAML2 アドオンの mappings オブジェクトを設定する方法:

```json lines theme={null}
"mappings": {
   "fav_genre": [
     "http://schemas.auth0.com/movies",
     "http://schemas.auth0.com/books",
     "http://schemas.auth0.com/television"
   ]
 }
```

このマッピングにより、次のようなレスポンスが返されます。

```xml lines theme={null}
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_e30cb5f29249a82846eb" InResponseTo="_e33996d83f953ce46225185b3a1c0ad8" Version="2.0" IssueInstant="2021-11-03T21:34:42.493Z" Destination="https://example-dev-tenant.us.auth0.com/login/callback">
...
       <saml:AttributeStatement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
           <saml:Attribute Name="http://schemas.auth0.com/movies" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
               <saml:AttributeValue xsi:type="xs:string">
                   fiction
               </saml:AttributeValue>
           </saml:Attribute>
           <saml:Attribute Name="http://schemas.auth0.com/books" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
               <saml:AttributeValue xsi:type="xs:string">
                   fiction
               </saml:AttributeValue>
           </saml:Attribute>
           <saml:Attribute Name="http://schemas.auth0.com/television" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
               <saml:AttributeValue xsi:type="xs:string">
                   fiction
               </saml:AttributeValue>
           </saml:Attribute>
...
       </saml:AttributeStatement>
   </saml:Assertion>
</samlp:Response>
```
