App Service web app authentication should be enabled

Description

Azure App Service Authentication is a feature that can prevent anonymous HTTP requests from reaching the API app, or authenticate those that have tokens before they reach the API app. If an anonymous request is received from a browser, App Service will redirect to a logon page. To handle the logon process, a choice from a set of identity providers can be made, or a custom authentication mechanism can be implemented.

Remediation Steps

Azure Portal

  • Navigate to App Services.

  • In the left navigation, select Authentication/Authorization.

  • In App Service Authentication, select On and click Save.

Azure CLI

  • To enable web app authentication, follow the Azure documentation for az webapp auth update and set --enabled true:

az webapp auth update --resource-group <RESOURCE_GROUP_NAME> --name <APP_NAME> --enabled true

Azure Resource Manager

For v1:

{
  "properties": {
    "enabled": true
  }
}

For v2:

{
  "properties": {
    "platform": {
      "enabled": true
    }
  }
}

Example Configuration

For v1:

{
  "type": "Microsoft.Web/sites/config",
  "apiVersion": "2021-02-01",
  "name": "authsettings",
  "properties": {
    "enabled": true
  }
  # other required fields here
}

For v2:

{
  "type": "Microsoft.Web/sites/config",
  "apiVersion": "2021-02-01",
  "name": "authsettingsV2",
  "properties": {
    "platform": {
      "enabled": true
    }
  }
  # other required fields here
}

Terraform

Example Configuration

resource "azurerm_app_service" "example" {
  auth_settings {
    enabled = true
  }

  # other required fields here
}