Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_app_service: Adds authentication support #2831

Merged
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
477facb
Add initial implementation for Authentication Settings in read & update
joakimhew Jan 30, 2019
10cd657
Add initial active directory section
joakimhew Feb 1, 2019
f227006
Add allowedAudiences to schema, flatten and expand
joakimhew Feb 1, 2019
69c6707
Add facebook auth settings schema
joakimhew Feb 1, 2019
627d41a
Add 'auth' to facebook schema function name
joakimhew Feb 1, 2019
54205f2
Add google auth settings schema
joakimhew Feb 1, 2019
7a46c0e
Make sure facebook app secret is required
joakimhew Feb 1, 2019
a7cf845
Add microsoft auth settings schema
joakimhew Feb 1, 2019
c033325
Add providers to main auth schema
joakimhew Feb 1, 2019
6c183e2
Add twitter auth settings schema
joakimhew Feb 1, 2019
902dea6
Add remaining properties for main schema
joakimhew Feb 1, 2019
04df693
Add facebook, google, microsoft and twitter to expand
joakimhew Feb 1, 2019
8b93fc8
Add facebook, google, microsoft and twitter to flatten
joakimhew Feb 1, 2019
92ed8b0
Add remaining main auth properties
joakimhew Feb 1, 2019
018ea10
Add remaining auth settings to flatten function
joakimhew Feb 1, 2019
eb7a104
Add check for providers
joakimhew Feb 1, 2019
3e117c8
Add acctest for Active Directory authentication
joakimhew Feb 1, 2019
9e042e6
Add missing check for Active Directory authentication
joakimhew Feb 1, 2019
8c799b9
Add acctest for Facebook authentication
joakimhew Feb 1, 2019
ac3ffc5
Add acctest for Google authentication
joakimhew Feb 1, 2019
e0912fc
Add acctest for Microsoft authentication
joakimhew Feb 1, 2019
6c32a36
Add acctest for Twitter authentication
joakimhew Feb 1, 2019
64f9c98
RandInt -> AccRandTimeInt
joakimhew Feb 1, 2019
806d98b
Check for nil interfaces in different auth settings
joakimhew Feb 1, 2019
0889395
Add acc test for multiple authentication providers
joakimhew Feb 1, 2019
6519171
Add acctests for remaining main auth settings
joakimhew Feb 1, 2019
8188811
Add Authentication documentation
joakimhew Feb 1, 2019
380c63c
Add token_store_enabled setting
joakimhew Feb 1, 2019
aebad28
Fix linting error when updating auth settings in read
joakimhew Feb 1, 2019
cc54d09
Add missing acceptance test for runtime version
joakimhew Feb 1, 2019
85a61bd
Update head and resolve comment about TypeMap for additional_login_pa…
joakimhew Apr 23, 2019
545b6be
Resolve comments from review for app_service.go
joakimhew Apr 23, 2019
9b18c1e
Explicitly cast before using expander function
joakimhew May 19, 2019
92da8f8
Add authentication examples to examples/app-service
joakimhew May 19, 2019
517b906
Resolve last comments from review
joakimhew May 19, 2019
447ffad
Fix linter error
joakimhew May 19, 2019
b2e0bbc
r/app_service: updating the docs per the PR comments
tombuildsstuff May 22, 2019
5a9e7fc
r/app_service: making `auth_settings` computed/the linux tests pass
tombuildsstuff May 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
549 changes: 549 additions & 0 deletions azurerm/helpers/azure/app_service.go

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions azurerm/resource_arm_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func resourceArmAppService() *schema.Resource {

"site_config": azure.SchemaAppServiceSiteConfig(),

"auth_settings": azure.SchemaAppServiceAuthSettings(),

"client_affinity_enabled": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -279,6 +281,17 @@ func resourceArmAppServiceCreate(d *schema.ResourceData, meta interface{}) error

d.SetId(*read.ID)

authSettingsRaw := d.Get("auth_settings").([]interface{})
authSettings := azure.ExpandAppServiceAuthSettings(authSettingsRaw)

auth := web.SiteAuthSettings{
ID: read.ID,
SiteAuthSettingsProperties: &authSettings}

if _, err := client.UpdateAuthSettings(ctx, resGroup, name, auth); err != nil {
return fmt.Errorf("Error updating auth settings for App Service %q (Resource Group %q): %+s", name, resGroup, err)
}

return resourceArmAppServiceUpdate(d, meta)
}

Expand Down Expand Up @@ -338,6 +351,20 @@ func resourceArmAppServiceUpdate(d *schema.ResourceData, meta interface{}) error
}
}

if d.HasChange("auth_settings") {
authSettingsRaw := d.Get("auth_settings").([]interface{})
authSettingsProperties := azure.ExpandAppServiceAuthSettings(authSettingsRaw)
id := d.Id()
authSettings := web.SiteAuthSettings{
ID: &id,
SiteAuthSettingsProperties: &authSettingsProperties,
}

if _, err := client.UpdateAuthSettings(ctx, resGroup, name, authSettings); err != nil {
return fmt.Errorf("Error updating Authentication Settings for App Service %q: %+v", name, err)
}
}

if d.HasChange("client_affinity_enabled") {

affinity := d.Get("client_affinity_enabled").(bool)
Expand Down Expand Up @@ -433,6 +460,11 @@ func resourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error making Read request on AzureRM App Service Configuration %q: %+v", name, err)
}

authResp, err := client.GetAuthSettings(ctx, resGroup, name)
if err != nil {
return fmt.Errorf("Error retrieving the AuthSettings for App Service %q (Resource Group %q): %+v", name, resGroup, err)
}

appSettingsResp, err := client.ListApplicationSettings(ctx, resGroup, name)
if err != nil {
if utils.ResponseWasNotFound(appSettingsResp.Response) {
Expand Down Expand Up @@ -496,6 +528,11 @@ func resourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error {
return err
}

authSettings := azure.FlattenAppServiceAuthSettings(authResp.SiteAuthSettingsProperties)
if err := d.Set("auth_settings", authSettings); err != nil {
return fmt.Errorf("Error setting `auth_settings`: %+s", err)
}

scm := flattenAppServiceSourceControl(scmResp.SiteSourceControlProperties)
if err := d.Set("source_control", scm); err != nil {
return err
Expand Down
Loading