App Service の組み込み認証設定の確認

保護するパスに適切な認証と認可を適用してください。

説明

管理ページや内部ツールなど、ログインが必要なパスを決め、App Service の組み込み認証またはアプリ独自の認証で保護します。意図して公開するパスには別途そのアクセス方針を適用してください。

想定される影響

ログインの有無やユーザーの権限を確かめないと、権限のない利用者がデータや管理機能にアクセスするおそれがあります。

対処方法

組み込み認証を使う場合は、構成に応じて auth_settings.enabled または auth_settings_v2.auth_enabled を有効にし、ID プロバイダーを設定します。保護対象のパスで匿名リクエストが拒否されるかログインに誘導されることを確認してください。ログイン済みでも必要なロールがなければ拒否されることも試します。

例

AzureRM 3.x の azurerm_app_service の例で有効にするのは認証機能だけです。プロバイダーと匿名リクエストの処理は別途設定してください。現在の構成では、OS に合わせて Linux または Windows Web App リソースを使います。

変更前

hcl
resource "azurerm_app_service" "example" {
  name                = "example-app-service"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_app_service_plan.example.id

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

  app_settings = {
    "SOME_KEY" = "some-value"
  }
}

変更後

hcl
resource "azurerm_app_service" "example" {
  name                = "example-app-service"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_app_service_plan.example.id

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

  app_settings = {
    "SOME_KEY" = "some-value"
  }

  auth_settings {
    enabled = true
  }
}

参考資料