Skip to content

Commit

Permalink
Add support_credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimhew committed Feb 14, 2019
1 parent d306913 commit dc2db73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions azurerm/helpers/azure/app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func SchemaAppServiceCorsSettings() *schema.Schema {
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"support_credentials": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
},
}
Expand Down Expand Up @@ -254,6 +259,10 @@ func ExpandAppServiceCorsSettings(input interface{}) web.CorsSettings {
corsSettings.AllowedOrigins = &allowedOrigins
}

if v, ok := setting["support_credentials"]; ok {
corsSettings.SupportCredentials = utils.Bool(v.(bool))
}

return corsSettings
}

Expand All @@ -272,6 +281,10 @@ func FlattenAppServiceCorsSettings(input *web.CorsSettings) []interface{} {
}
result["allowed_origins"] = allowedOrigins

if input.SupportCredentials != nil {
result["support_credentials"] = *input.SupportCredentials
}

return append(results, result)
}

Expand Down
4 changes: 3 additions & 1 deletion azurerm/resource_arm_app_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@ func TestAccAzureRMAppService_corsSettings(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "site_config.0.cors.#", "1"),
resource.TestCheckResourceAttr(resourceName, "site_config.0.cors.0.support_credentials", "true"),
resource.TestCheckResourceAttr(resourceName, "site_config.0.cors.0.allowed_origins.#", "3"),
resource.TestCheckResourceAttr(resourceName, "site_config.0.cors.0.allowed_origins.0", "http://www.contoso.com"),
resource.TestCheckResourceAttr(resourceName, "site_config.0.cors.0.allowed_origins.1", "www.contoso.com"),
Expand Down Expand Up @@ -2472,7 +2473,8 @@ resource "azurerm_app_service" "test" {
"http://www.contoso.com",
"www.contoso.com",
"contoso.com"
]
]
support_credentials = true
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ The following attributes are exported:

* `allowed_origins` - (Required) List of allowed origins

* `support_credentials` - (Optional) Should credential headers be allowed? Defaults to `false`.

## Import

App Services can be imported using the `resource id`, e.g.
Expand Down

0 comments on commit dc2db73

Please sign in to comment.