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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update head and resolve comment about TypeMap for additional_login_pa…
…rams
joakimhew committed May 19, 2019
commit 85a61bdff20e3d667df72d01fedc55625835b18c
30 changes: 20 additions & 10 deletions azurerm/helpers/azure/app_service.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package azure

import (
"fmt"
"log"
"net"
"strings"
@@ -152,9 +153,8 @@ func SchemaAppServiceAuthSettings() *schema.Schema {
Sensitive: false,
joakimhew marked this conversation as resolved.
Show resolved Hide resolved
},
"additional_login_params": {
Type: schema.TypeList,
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"allowed_external_redirect_urls": {
Type: schema.TypeList,
@@ -666,11 +666,11 @@ func ExpandAppServiceAuthSettings(input interface{}) web.SiteAuthSettingsPropert
}

if v, ok := setting["additional_login_params"]; ok {
input := v.([]interface{})
input := v.(map[string]interface{})

additionalLoginParams := make([]string, 0)
for _, param := range input {
additionalLoginParams = append(additionalLoginParams, param.(string))
for k, v := range input {
additionalLoginParams = append(additionalLoginParams, fmt.Sprintf("%s=%s", k, v.(string)))
}

siteAuthSettingsProperties.AdditionalLoginParams = &additionalLoginParams
@@ -858,6 +858,20 @@ func ExpandAppServiceAuthSettings(input interface{}) web.SiteAuthSettingsPropert
return siteAuthSettingsProperties
}

func FlattenAdditionalLoginParams(input *[]string) map[string]interface{} {
result := make(map[string]interface{}, len(*input))
joakimhew marked this conversation as resolved.
Show resolved Hide resolved

for _, k := range *input {
joakimhew marked this conversation as resolved.
Show resolved Hide resolved
parts := strings.Split(k, "=")
joakimhew marked this conversation as resolved.
Show resolved Hide resolved
key := parts[0]
value := parts[1]

result[key] = value
}

return result
}

func FlattenAppServiceAuthSettings(input *web.SiteAuthSettingsProperties) []interface{} {
results := make([]interface{}, 0)
result := make(map[string]interface{})
@@ -871,11 +885,7 @@ func FlattenAppServiceAuthSettings(input *web.SiteAuthSettingsProperties) []inte
result["enabled"] = *input.Enabled
}

additionalLoginParams := make([]string, 0)
if s := input.AdditionalLoginParams; s != nil {
additionalLoginParams = *s
}
result["additional_login_params"] = additionalLoginParams
result["additional_login_params"] = FlattenAdditionalLoginParams(input.AdditionalLoginParams)

allowedExternalRedirectUrls := make([]string, 0)
if s := input.AllowedExternalRedirectUrls; s != nil {
9 changes: 4 additions & 5 deletions azurerm/resource_arm_app_service_test.go
Original file line number Diff line number Diff line change
@@ -1347,8 +1347,7 @@ func TestAccAzureRMAppService_authSettingsAdditionalLoginParams(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "auth_settings.0.enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "auth_settings.0.additional_login_params.#", "1"),
resource.TestCheckResourceAttr(resourceName, "auth_settings.0.additional_login_params.0", "someloginparam"),
resource.TestCheckResourceAttr(resourceName, "auth_settings.0.additional_login_params.test_key", "test_value"),
resource.TestCheckResourceAttr(resourceName, "auth_settings.0.issuer", fmt.Sprintf("https://sts.windows.net/%s", tenantID)),
resource.TestCheckResourceAttr(resourceName, "auth_settings.0.active_directory.0.client_id", "aadclientid"),
resource.TestCheckResourceAttr(resourceName, "auth_settings.0.active_directory.0.client_secret", "aadsecret"),
@@ -3088,9 +3087,9 @@ resource "azurerm_app_service" "test" {
enabled = true
issuer = "https://sts.windows.net/%s"

additional_login_params = [
"someloginparam"
]
additional_login_params = {
test_key = "test_value"
}

active_directory {
client_id = "aadclientid"