メインコンテンツへスキップ
Auth0 が の場合、Auth0 の SAML2 アドオンを使用してユーザー属性をマッピングできます。属性の設定が誤っていると、エラーが発生することがあります。たとえば、ユーザーは username と password を正しく入力しているのに、 のログにはログイン成功イベントが記録されているにもかかわらず、アプリケーションにサインインできない場合があります。また、アプリケーションで 名前 や メールアドレス などのユーザー情報が取得できないこともあります。

ユースケース

以下のユーザープロファイルは、次のシナリオで使用する例です。
//サンプル IdP ユーザープロファイル
{
   "created_at": "2021-06-21T13:26:08.579Z",
   "email": "testuser@example.com",
...
   "fav_genre": "fiction",
   "user_metadata": {
       "fav_streaming_service": "hulu"
   }
...
}

mappings オブジェクトなし

SAML2 アドオンを使用すると、空の mappings オブジェクトがデフォルトで生成されます。 この例では、fav_genreuser_metadata.fav_streaming_service は未定義ですが、カスタマイズして、Auth0 によって生成される レスポンスにマッピングできます。 以下の例では、"fav_genre": "fiction"fiction の値を持つ http://schemas.auth0.com/fav_genre 属性として SAML レスポンスにマッピングされますが、"user_metadata": {"fav_streaming_service": "hulu"} は SAML レスポンスにはまったく含まれません。 IdP が送信する最終的な SAML レスポンス:
<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>

標準マッピングの例

前の例では、mappings オブジェクト をカスタマイズしなかったため、SAML レスポンス には値 "fiction" を持つ http://schemas.auth0.com/fav_genre 属性が含まれていました。 次に、それに対応するように、SAML2 アドオン settings の mappings オブジェクト で属性をマッピングします。 これを行うと、SAML レスポンス 内の "fiction" 値は同じままですが、属性名はデフォルトの http://schemas.auth0.com/fav_fiction から http://schemas.auth0.com/books に変更されていることがわかります。 SAML2 アドオン の mappings オブジェクト の設定:
"mappings": {
   "fav_genre": "http://schemas.auth0.com/books"
 }
このマッピングにより、次のようなレスポンスが返されます。
<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>

同じ値を複数の属性にマッピングする

同じ値を SAML レスポンス の複数の属性にマッピングする必要がある場合があります。 この場合、ユーザープロファイル内の同じ値を SAML レスポンス の複数の属性にマッピングできます。 SAML2 アドオンの mappings オブジェクトを設定する方法:
"mappings": {
   "fav_genre": [
     "http://schemas.auth0.com/movies",
     "http://schemas.auth0.com/books",
     "http://schemas.auth0.com/television"
   ]
 }
このマッピングにより、次のようなレスポンスが返されます。
<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>