Review App Service built-in authentication

Apply appropriate authentication and authorization to protected paths.

Description

Identify the paths that need sign-in, such as admin pages and internal tools. Protect them with App Service authentication or the app’s own authentication, and keep intentionally public routes available.

Potential impact

Skipping sign-in or permission checks on protected paths can expose data or administrative functions.

Remediation

For built-in authentication, enable auth_settings.enabled or auth_settings_v2.auth_enabled as appropriate and configure an identity provider. Check that a protected path rejects anonymous requests or redirects them to sign-in. Then test that a signed-in user without the required role is denied.

Examples

The AzureRM 3.x azurerm_app_service excerpts only enable the feature. Supply the provider and anonymous-request policy separately. For current configurations, use the Linux or Windows Web App resource for your app.

Before

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"
  }
}

After

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

References