> ## 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がアイデンティティプロバイダーである場合に、SAML属性をマッピングする方法の例を紹介します。

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

Auth0が<Tooltip tip="アイデンティティプロバイダー（IdP）: デジタルアイデンティティを保存および管理するサービス。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=IdP">IdP</Tooltip>である場合、Auth0 の SAML2 add-on を使ってユーザー属性をマッピングできます。属性の設定が誤っていると、エラーが発生することがあります。たとえば、ユーザーがユーザー名とパスワードを正しく入力しても、<Tooltip tip="Auth0 Dashboard: サービスを設定するためのAuth0の主要製品。" cta="用語集を見る" href="/docs/ja-jp/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 object がない場合
</div>

SAML2 add-on を使用すると、デフォルトで空の mappings object が生成されます。

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

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

IdP が送信する生成後の SAML Response:

```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">
  #### 標準的な mappings の例
</div>

前の例では、mappings object をカスタマイズしなかったため、SAML Response には `"fiction"` という値を持つ [http://schemas.auth0.com/fav\_genre](http://schemas.auth0.com/fav_food) attribute が含まれていました。

次に、それを反映させるために、SAML2 add-on の設定にある Mappings Object で 属性 をマッピングします。

その後、SAML Response 内の `"fiction"` という値は同じままですが、SAML Response の attribute 名が既定の [http://schemas.auth0.com/fav\_fiction](http://schemas.auth0.com/fav_food) から [http://schemas.auth0.com/books](http://schemas.auth0.com/dinner) に変更されていることがわかります。

SAML2 add-on の mappings object の設定:

```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 Response で同じ値を複数の属性にマッピングする必要がある場合があります。

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

SAML2 add-on の mappings object を設定する方法:

```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>
```
