次の方法で共有


Microsoft Graph API を使用してアプリケーション プロキシMicrosoft Entra構成する

Microsoft Entra アプリケーション プロキシは、セキュリティで保護されたリモート アクセスと、オンプレミスの Web アプリケーションへのシングル サインオン (SSO) を提供します。 これにより、ユーザーは、外部 URL、マイ アプリ ポータル、またはその他の内部アプリケーション ポータルを使用して、オンプレミス アプリケーションにアクセスできます。

このチュートリアルでは、Microsoft Graph API を使用してアプリケーション プロキシMicrosoft Entra構成する方法について説明します。

重要

現在、アプリ プロキシ固有の API 操作は、 beta エンドポイントでのみ使用できます。

前提条件

  • コネクタをインストールし、コネクタがMicrosoft Entra サービスと通信できるように、アプリケーション プロキシの前提条件を満たします。
  • Graph エクスプローラー などの API クライアントに、少なくともクラウド アプリケーション管理者ロールを持つアカウントでサインインします。
  • 委任されたアクセス許可を Microsoft Graph Directory.ReadWrite.All 自分に付与します。
  • アプリケーションに割り当てるテスト ユーザーがいます。

手順 1: カスタム アプリケーションを作成する

アプリケーション プロキシを構成するには、まずカスタム アプリケーションを作成してから、アプリケーションの onPremisesPublishing プロパティでアプリ プロキシ設定を更新します。 このチュートリアルでは、アプリケーション テンプレートを使用して、テナントにカスタム アプリケーションとサービス プリンシパルのインスタンスを作成します。 カスタム アプリケーションのテンプレート ID が 8adf8e6e-67b2-4cf2-a259-e3dc5476c621され、 GET https://graph.microsoft.com/v1.0/applicationTemplates?$filter=displayName eq 'Custom' というクエリを実行して検出できます。

応答から、サービス プリンシパルとアプリケーション オブジェクトの両方の ID と、チュートリアルの後半で使用する appId の値を記録します。

要求

POST https://graph.microsoft.com/v1.0/applicationTemplates/8adf8e6e-67b2-4cf2-a259-e3dc5476c621/instantiate
Content-type: application/json

{
  "displayName": "Contoso IWA App"
}

応答

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.applicationServicePrincipal",
    "application": {
        "id": "bf21f7e9-9d25-4da2-82ab-7fdd85049f83",
        "appId": "32977d3b-ee0e-4614-9f50-f583a07842d2",
        "applicationTemplateId": "8adf8e6e-67b2-4cf2-a259-e3dc5476c621",
        "createdDateTime": "2024-02-22T16:48:09Z",
        "deletedDateTime": null,
        "displayName": "Contoso IWA App",
        "description": null,
        "groupMembershipClaims": null,
        "identifierUris": [],
        "isFallbackPublicClient": false,
        "signInAudience": "AzureADMyOrg",
        "tags": [],
        "tokenEncryptionKeyId": null,
        "defaultRedirectUri": null,
        "samlMetadataUrl": null,
        "optionalClaims": null,
        "addIns": [],
        "api": {
            "acceptMappedClaims": null,
            "knownClientApplications": [],
            "requestedAccessTokenVersion": null,
            "oauth2PermissionScopes": [
                {
                    "adminConsentDescription": "Allow the application to access Contoso IWA App on behalf of the signed-in user.",
                    "adminConsentDisplayName": "Access Contoso IWA App",
                    "id": "5cda2e1e-d9fd-4f69-b981-48fbc8a16be1",
                    "isEnabled": true,
                    "type": "User",
                    "userConsentDescription": "Allow the application to access Contoso IWA App on your behalf.",
                    "userConsentDisplayName": "Access Contoso IWA App",
                    "value": "user_impersonation"
                }
            ],
            "preAuthorizedApplications": []
        },
        "appRoles": [
            {
                "allowedMemberTypes": [
                    "User"
                ],
                "displayName": "User",
                "id": "18d14569-c3bd-439b-9a66-3a2aee01d14f",
                "isEnabled": true,
                "description": "User",
                "value": null,
                "origin": "Application"
            },
            {
                "allowedMemberTypes": [
                    "User"
                ],
                "displayName": "msiam_access",
                "id": "b9632174-c057-4f7e-951b-be3adc52bfe6",
                "isEnabled": true,
                "description": "msiam_access",
                "value": null,
                "origin": "Application"
            }
        ],
        "info": {
            "logoUrl": null,
            "marketingUrl": null,
            "privacyStatementUrl": null,
            "supportUrl": null,
            "termsOfServiceUrl": null
        },
        "keyCredentials": [],
        "parentalControlSettings": {
            "countriesBlockedForMinors": [],
            "legalAgeGroupRule": "Allow"
        },
        "passwordCredentials": [],
        "publicClient": {
            "redirectUris": []
        },
        "requiredResourceAccess": [],
        "verifiedPublisher": {
            "displayName": null,
            "verifiedPublisherId": null,
            "addedDateTime": null
        },
        "web": {
            "homePageUrl": "https://account.activedirectory.windowsazure.com:444/applications/default.aspx?metadata=customappsso|ISV9.1|primary|z",
            "redirectUris": [],
            "logoutUrl": null
        }
    },
    "servicePrincipal": {
        "id": "a8cac399-cde5-4516-a674-819503c61313",
        "deletedDateTime": null,
        "accountEnabled": true,
        "appId": "32977d3b-ee0e-4614-9f50-f583a07842d2",
        "applicationTemplateId": "8adf8e6e-67b2-4cf2-a259-e3dc5476c621",
        "appDisplayName": "Contoso IWA App",
        "alternativeNames": [],
        "appOwnerOrganizationId": "38d49456-54d4-455d-a8d6-c383c71e0a6d",
        "displayName": "Contoso IWA App",
        "appRoleAssignmentRequired": true,
        "loginUrl": null,
        "logoutUrl": null,
        "homepage": "https://account.activedirectory.windowsazure.com:444/applications/default.aspx?metadata=customappsso|ISV9.1|primary|z",
        "notificationEmailAddresses": [],
        "preferredSingleSignOnMode": null,
        "preferredTokenSigningKeyThumbprint": null,
        "replyUrls": [],
        "servicePrincipalNames": [
            "32977d3b-ee0e-4614-9f50-f583a07842d2"
        ],
        "servicePrincipalType": "Application",
        "tags": [
            "WindowsAzureActiveDirectoryCustomSingleSignOnApplication",
            "WindowsAzureActiveDirectoryIntegratedApp"
        ],
        "tokenEncryptionKeyId": null,
        "samlSingleSignOnSettings": null,
        "addIns": [],
        "appRoles": [
            {
                "allowedMemberTypes": [
                    "User"
                ],
                "displayName": "User",
                "id": "18d14569-c3bd-439b-9a66-3a2aee01d14f",
                "isEnabled": true,
                "description": "User",
                "value": null,
                "origin": "Application"
            },
            {
                "allowedMemberTypes": [
                    "User"
                ],
                "displayName": "msiam_access",
                "id": "b9632174-c057-4f7e-951b-be3adc52bfe6",
                "isEnabled": true,
                "description": "msiam_access",
                "value": null,
                "origin": "Application"
            }
        ],
        "info": {
            "logoUrl": null,
            "marketingUrl": null,
            "privacyStatementUrl": null,
            "supportUrl": null,
            "termsOfServiceUrl": null
        },
        "keyCredentials": [],
        "oauth2PermissionScopes": [
            {
                "adminConsentDescription": "Allow the application to access Contoso IWA App on behalf of the signed-in user.",
                "adminConsentDisplayName": "Access Contoso IWA App",
                "id": "5cda2e1e-d9fd-4f69-b981-48fbc8a16be1",
                "isEnabled": true,
                "type": "User",
                "userConsentDescription": "Allow the application to access Contoso IWA App on your behalf.",
                "userConsentDisplayName": "Access Contoso IWA App",
                "value": "user_impersonation"
            }
        ],
        "passwordCredentials": [],
        "verifiedPublisher": {
            "displayName": null,
            "verifiedPublisherId": null,
            "addedDateTime": null
        }
    }
}

手順 2: アプリケーション プロキシを構成する

手順 1 で作成したアプリについて、アプリケーションの URI を構成します。 アプリの内部 URL が https://contosoiwaapp.com され、外部 URL の既定のドメインが https://contosoiwaapp-contoso.msappproxy.netされているとします。 外部 URL 値を identifierUrisweb>redirectUrisWeb>homePageUrl プロパティに追加します。

また、必要に応じて 、onPremisesPublishing プロパティを 構成して、内部 URL と外部 URL、およびその他のプロパティを設定します。 このプロパティは beta でのみ使用でき、URI を構成するまで構成できません。

手順 2.1: URI を構成する

次の要求では、identifierUris プロパティに appId の値を使用します。 また、Microsoft Entra IDで予期されるアプリケーション ID URI 形式と一致するその他の識別子を使用することもできます。 要求は、 204 No content 応答を返します。

PATCH https://graph.microsoft.com/v1.0/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83
Content-type: application/json

{
    "identifierUris": [
        "api://32977d3b-ee0e-4614-9f50-f583a07842d2"
    ],
    "web": {
        "redirectUris": [
            "https://contosoiwaapp-contoso.msappproxy.net"
        ],
        "homePageUrl": "https://contosoiwaapp-contoso.msappproxy.net"
    }
}

手順 2.2: onPremisesPublishing プロパティを構成する

要求は、 204 No content 応答を返します。

PATCH https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83
Content-type: application/json

{
    "onPremisesPublishing": {
        "externalAuthenticationType": "aadPreAuthentication",
        "internalUrl": "https://contosoiwaapp.com",
        "externalUrl": "https://contosoiwaapp-contoso.msappproxy.net",
        "isHttpOnlyCookieEnabled": true,
        "isOnPremPublishingEnabled": true,
        "isPersistentCookieEnabled": true,
        "isSecureCookieEnabled": true,
        "isStateSessionEnabled": true,
        "isTranslateHostHeaderEnabled": true,
        "isTranslateLinksInBodyEnabled": true
    }
}

手順 3: コネクタ グループをアプリケーションに割り当てる

手順 3.1: コネクタを取得する

コネクタ グループに割り当てるコネクタを特定します。 ID を記録します

要求

GET https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors

応答

HTTP/1.1 200 OK
Content-type: application/json

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#onPremisesPublishingProfiles('applicationProxy')/connectors",
    "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET onPremisesPublishingProfiles('<key>')/connectors?$select=externalIp,machineName",
    "value": [
    {
      "id": "d2b1e8e8-8511-49d6-a4ba-323cb083fbb0",
      "machineName": "connectorA.redmond.contoso.com"",
      "externalIp": "131.137.147.164",
      "status": "active"
    },
    {
      "id": "f2cab422-a1c8-4d70-a47e-2cb297a2e051",
      "machineName": "connectorB.contoso.com"",
      "externalIp": "68.0.191.210",
      "status": "active"
    }
  ]
}

手順 3.2: コネクタ グループを作成する

アプリケーションの IWA Demo Connector Group という名前の connectorGroup を作成します。 ID を記録します

要求

POST https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups
Content-type: application/json

{
  "name": "IWA Demo Connector Group"
}

応答

HTTP/1.1 201 Created
Content-type: application/json

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#connectorGroups/$entity",
  "id": "3e6f4c35-a04b-4d03-b98a-66fff89b72e6",
  "name": "IWA Demo Connector Group",
  "connectorGroupType": "applicationProxy",
  "region": "eur",
  "isDefault": false
}

手順 3.3: コネクタを connectorGroup に割り当てる

要求は、 204 No content 応答を返します。

POST https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors/f2cab422-a1c8-4d70-a47e-2cb297a2e051/memberOf/$ref
Content-type: application/json

{
  "@odata.id":"https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups/3e6f4c35-a04b-4d03-b98a-66fff89b72e6"
}

手順 3.4: アプリケーションを connectorGroup に割り当てる

要求は、 204 No content 応答を返します。

PUT https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83/connectorGroup/$ref
Content-type: application/json

{
  "@odata.id":"https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationproxy/connectorGroups/3e6f4c35-a04b-4d03-b98a-66fff89b72e6"
}

手順 4: シングル サインオン (SSO) を構成する

この手順では、アプリケーション の singleSignOnMode プロパティ > singleSignOnSettings プロパティと onPremisesPublishing > singleSignOnMode プロパティを構成します。

オプション 1: IWA ベースの SSO を構成する

次の要求は、アプリケーションの統合 Windows 認証 (IWA) を構成する方法を示しています。 要求は、 204 No content 応答を返します。

PATCH https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83
Content-type: appplication/json

{
  "onPremisesPublishing": {
    "singleSignOnSettings": {
      "kerberosSignOnSettings": {
        "kerberosServicePrincipalName": "HTTP/iwademo.contoso.com",
           "kerberosSignOnMappingAttributeType": "userPrincipalName"
      },
      "singleSignOnMode": "onPremisesKerberos"
    }
  } 
}

オプション 2: ヘッダー ベースの SSO を構成する

次の要求は、アプリケーションのヘッダー ベースの SSO を構成する方法を示しています。 このモードでは、 singleSignOnMode プロパティの値は、 aadHeaderBasedpingHeaderBased、または oAuthTokenできます。 要求は、 204 No content 応答を返します。

PATCH https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83
Content-type: appplication/json

{
  "onPremisesPublishing": {
    "singleSignOnSettings": {
      "kerberosSignOnSettings": {},
      "singleSignOnMode": "aadHeaderBased"
    }
  } 
}

手順 5: アプリケーションにユーザーを割り当てる

アプリケーションにユーザーを割り当てる必要があります。 手順 1 で作成したサービス プリンシパルから、appRoles プロパティで定義されている既定のユーザー ロールの ID を記録します。 この値は 18d14569-c3bd-439b-9a66-3a2aee01d14f

要求本文で、次の値を指定します。

  • principalId - 作成したユーザー アカウントの ID。
  • appRoleId - サービス プリンシパルから取得した既定の User アプリ ロールの ID。
  • resourceId - サービス プリンシパルの ID。

要求

POST https://graph.microsoft.com/beta/servicePrincipals/a8cac399-cde5-4516-a674-819503c61313/appRoleAssignments
Content-type: application/json

{
  "principalId": "2fe96d23-5dc6-4f35-8222-0426a8c115c8",
  "principalType": "User",
  "appRoleId":"18d14569-c3bd-439b-9a66-3a2aee01d14f",
  "resourceId":"a8cac399-cde5-4516-a674-819503c61313"
}

応答

HTTP/1.1 200 OK
Content-type: application/json

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#appRoleAssignments/$entity",
  "id": "I23pL8ZdNU-CIgQmqMEVyLJ0E6fx0ixEo92az8MnhtU",
  "creationTimestamp": "2020-06-09T00:06:07.5129268Z",
  "appRoleId": "18d14569-c3bd-439b-9a66-3a2aee01d14f",
  "principalDisplayName": "MyTestUser1",
  "principalId": "2fe96d23-5dc6-4f35-8222-0426a8c115c8",
  "principalType": "User",
  "resourceDisplayName": "Contoso IWA App",
  "resourceId": "a8cac399-cde5-4516-a674-819503c61313"
}

手順 6: アプリケーションへのアクセスをテストする

ブラウザーでアプリ用に構成されている externalUrl にアクセスし、テスト ユーザーとサインインしてアプリケーションをテストします。 アプリにサインインし、アプリケーションにアクセスできる必要があります。

手順 7: リソースをクリーンアップする

この手順では、作成したリソースを削除し、不要になったリソースを削除します。

ユーザー アカウントを削除する

要求は、 204 No content 応答を返します。

DELETE https://graph.microsoft.com/v1.0/users/4628e7df-dff3-407c-a08f-75f08c0806dc

アプリケーションを削除する

アプリケーションを削除すると、テナント内のサービス プリンシパルも削除されます。 この要求は、 204 No content 応答を返します。

DELETE https://graph.microsoft.com/v1.0/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83

コネクタ グループを削除する

要求は、 204 No content 応答を返します。

DELETE https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups/3e6f4c35-a04b-4d03-b98a-66fff89b72e6