サインアップ時に収集された属性を検証する
演習 - サインアップ時に収集された属性を検証する
カスタム認証拡張機能では、on attribute collection submit イベントがサポートされます。 このイベントを使用すると、サインアップ時にユーザーから収集された属性に対して検証を実行できます。 食料品の Web サイトでは、カスタム認証拡張機能 REST API でコンパイルされた countries の一覧に対して City 名を検証します。 また、市区町村に block が含まれている場合、Microsoft Entra 外部 ID には block ページが表示されます。 市区町村に modify が含まれている場合、Microsoft Entra 外部 ID によって一部の属性 (表示名と市区町村) が変更されます
Note
サインアップ時に収集される属性の検証を構成するには、少なくとも認証拡張性の管理者ディレクトリ ロールが必要です。
このロールは特権ロールです。 特権ロールを使用するためのベスト プラクティスについてお読みください。
フィードバックがありますか? ご自身の概念実証プロジェクトがどのように進んでいるかをお知らせください。 ご意見をお聞かせください!
ヒント
また、さまざまなイベントに対して Microsoft Entra 外部 ID のカスタム認証拡張機能を使用する方法を示す .NET C# Web API の例を、ここから表示することもできます。
まず、Microsoft Entra 外部 ID によって REST API を呼び出すために使用されるカスタム認証拡張機能を登録します。 カスタム認証拡張機能には、REST API エンドポイント、REST API から解析する属性コレクションの開始アクション、および REST API に対する認証方法に関する情報が含まれています。 Microsoft Entra 管理センターにサインインし、[外部 ID]>[Custom authentication extensions] (カスタム認証拡張機能) を参照します。 [アプリケーション]>[エンタープライズ アプリケーション]>[Custom authentication extensions] (カスタム認証拡張機能)から参照することもできます。 次に、[カスタム拡張機能の作成] を選択します。
[基本情報]で、AttributeCollectionSubmit イベントを選択し、[次へ] を選択します。
[エンドポイントの構成] で、次のプロパティを入力します。
カスタム認証拡張機能と REST API の間の通信を適切にセキュリティで保護するには、複数のセキュリティ制御を適用する必要があります。 最初の手順として、Microsoft Entra 外部 ID で使用するアプリケーションを作成または選択します。 OAuth 2.0 クライアント資格情報の許可フローを使用して、API エンドポイントへの呼び出しをセキュリティで保護します。
これが初めてのカスタム認証拡張機能の場合は、TokenIssuanceStart イベントを構成した方法を確認してください。 カスタム認証拡張機能は既に構成されているため、[API 認証] で、[このディレクトリ内の既存のアプリ登録を選択] オプションを選択します。
他のカスタム認証拡張機能用に構成したアプリケーションを選択し、[選択] を選択します。
構成を確認し、[作成] を選択します。構成したカスタム認証拡張機能と、選択した関連付けられているアプリケーション登録が登録されます。
この時点で、カスタム認証拡張機能はテナントで構成されますが、どのサインアップ ページでも使用されません。 次に、カスタム認証拡張機能を 1 つ以上のユーザー フローに関連付けます。 これを行うには、[ID]>[Azure Active Directory External Identities]>[ユーザー フロー] に移動します。 次に、一覧からユーザー フローを選択します。
メニューから [カスタム認証拡張機能] を選択します。 カスタム認証拡張機能を関連付けるには、Before collecting information from the user イベントを選択します。
OnAttributeCollectionStart イベント用に構成されたカスタム拡張機能が表示されます。 属性コレクションの開始イベントに対していずれか 1 つを選択し、[選択] を選択して変更を保存します。
お疲れさまでした。これで、OnAttributeCollectionSubmit 型のカスタム認証拡張機能を作成し、それをユーザー フローに関連付けました。
1.カスタム認証拡張機能アプリケーションを登録する
これが初めてのカスタム認証拡張機能の場合は、カスタム認証拡張機能アプリケーションを登録します。
2.カスタム認証拡張機能を登録する
次に、カスタム認証拡張機能を登録します。 カスタム認証拡張機能を登録するには、作成した Custom authentication extension security app を REST API エンドポイントに関連付けます。 次の値を独自の値に置き換えます。 - {app-ID} は、直前に呼び出した Custom authentication extension security app のアプリ ID。 - {REST-API-domain} は、rest API ドメイン名 - {Endpoint-URL} は、REST API エンドポイントの RUL
POST https://graph.microsoft.com/beta/identity/customAuthenticationExtensions
{
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitCustomExtension",
"displayName": "Validate sign-up user input",
"description": "Validate user input including the city name and may ask the user to correct the data or block the user",
"behaviorOnError": null,
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://{REST-API-domain}/{app-ID}"
},
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "{Endpoint-URL}"
},
"clientConfiguration": {
"timeoutInMilliseconds": null,
"maximumRetries": null
}
}
例
POST https://graph.microsoft.com/beta/identity/customAuthenticationExtensions
{
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitCustomExtension",
"displayName": "Validate sign-up user input",
"description": "Validate user input including the city name and may ask the user to correct the data or block the user",
"behaviorOnError": null,
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://auth-api.woodgrovedemo.com/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1"
},
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://auth-api.woodgrovedemo.com/OnAttributeCollectionSubmit"
},
"clientConfiguration": {
"timeoutInMilliseconds": null,
"maximumRetries": null
}
}
2.1 カスタム認証拡張機能 ID をコピーする
応答から、id の値をコピーします。次に例を示します。
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#identity/customAuthenticationExtensions/$entity",
"@odata.type": "#microsoft.graph.onAttributeCollectionStartCustomExtension",
"id": "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb",
"displayName": "Prepopulate sign-up attributes",
"description": "Prepopulate sign-up attributes from a REST API",
}
2.2 認証イベント リスナーを作成する
カスタム認証拡張機能を登録した後、認証イベント リスナーを作成します。 次の JSON では、{Custom-auth-extension-ID} を、先ほど作成したカスタム認証拡張機能に置き換えます。
POST https://graph.microsoft.com/beta/identity/authenticationEventListeners
{
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitListener",
"conditions": {
"applications": {
"includeAllApplications": false,
"includeApplications": []
}
},
"priority": 500,
"handler": {
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitCustomExtensionHandler",
"customExtension": {
"id": "{Custom-auth-extension-ID}"
}
}
}
例
POST https://graph.microsoft.com/beta/identity/authenticationEventListeners
{
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitListener",
"conditions": {
"applications": {
"includeAllApplications": false,
"includeApplications": []
}
},
"priority": 500,
"handler": {
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitCustomExtensionHandler",
"customExtension": {
"id": "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb"
}
}
}
2.3 カスタム認証拡張機能をユーザー フローにリンクする
ユーザー フローを更新します。 次の要求で、次の値を独自の値に置き換えます。 - {user-flow-ID} は、ユーザー フロー ID。 - {Custom-auth-extension-ID} は、先ほど作成したカスタム認証拡張機能。
PUT https://graph.microsoft.com/beta/identity/authenticationEventsFlows/{user-flow-ID}/microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAttributeCollectionSubmit/microsoft.graph.onAttributeCollectionSubmitCustomExtensionHandler/customExtension/$ref
{
"@odata.id": "https://graph.microsoft.com/beta/identity/customAuthenticationExtensions/{Custom-auth-extension-ID}"
}
例
PUT https://graph.microsoft.com/beta//identity/authenticationEventsFlows/bbbbbbbb-1111-2222-3333-cccccccccccc/microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAttributeCollectionSubmit/microsoft.graph.onAttributeCollectionSubmitCustomExtensionHandler/customExtension/$ref
{
"@odata.id": "https://graph.microsoft.com/beta/identity/customAuthenticationExtensions/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb"
}