diff --git a/CHANGELOG.md b/CHANGELOG.md index ce840533..663a714a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 0.25.1 + +ENHANCEMENTS: + +* resource/client: Add the `native_social_login` field for native `app_types` ([#453](https://github.com/alexkappa/terraform-provider-auth0/pull/453)) + +NOTES: + +* Fix role docs [#398](https://github.com/alexkappa/terraform-provider-auth0/pull/398) + ## 0.25.0 ENHANCEMENTS: diff --git a/auth0/resource_auth0_client.go b/auth0/resource_auth0_client.go index 0a31d87e..066b15da 100644 --- a/auth0/resource_auth0_client.go +++ b/auth0/resource_auth0_client.go @@ -496,6 +496,42 @@ func newClient() *schema.Resource { v.IsURLWithNoFragment, ), }, + "native_social_login": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "apple": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Optional: true, + }, + }, + }, + }, + "facebook": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Optional: true, + }, + }, + }, + }, + }, + }, + }, "refresh_token": { Type: schema.TypeList, Optional: true, @@ -595,6 +631,7 @@ func readClient(d *schema.ResourceData, m interface{}) error { d.Set("custom_login_page", c.CustomLoginPage) d.Set("form_template", c.FormTemplate) d.Set("token_endpoint_auth_method", c.TokenEndpointAuthMethod) + d.Set("native_social_login", flattenCustomSocialConfiguration(c.NativeSocialLogin)) d.Set("jwt_configuration", flattenClientJwtConfiguration(c.JWTConfiguration)) d.Set("refresh_token", flattenClientRefreshTokenConfiguration(c.RefreshToken)) d.Set("encryption_key", c.EncryptionKey) @@ -747,6 +784,24 @@ func expandClient(d *schema.ResourceData) *management.Client { } } + List(d, "native_social_login").Elem(func(d ResourceData) { + c.NativeSocialLogin = &management.ClientNativeSocialLogin{} + + List(d, "apple").Elem(func(d ResourceData) { + m := make(MapData) + m.Set("enabled", Bool(d, "enabled")) + + c.NativeSocialLogin.Apple = m + }) + + List(d, "facebook").Elem(func(d ResourceData) { + m := make(MapData) + m.Set("enabled", Bool(d, "enabled")) + + c.NativeSocialLogin.Facebook = m + }) + }) + List(d, "mobile").Elem(func(d ResourceData) { c.Mobile = make(map[string]interface{}) @@ -820,6 +875,27 @@ func clientHasChange(c *management.Client) bool { return c.String() != "{}" } +func flattenCustomSocialConfiguration(customSocial *management.ClientNativeSocialLogin) []interface{} { + if customSocial != nil { + m := make(map[string]interface{}) + + if customSocial.Apple != nil { + m["apple"] = map[string]interface{}{ + "enabled": customSocial.Apple["enabled"], + } + } + if customSocial.Facebook != nil { + m["facebook"] = map[string]interface{}{ + "enabled": customSocial.Facebook["enabled"], + } + } + + return []interface{}{m} + } + + return nil +} + func flattenClientJwtConfiguration(jwt *management.ClientJWTConfiguration) []interface{} { m := make(map[string]interface{}) if jwt != nil { diff --git a/auth0/resource_auth0_client_test.go b/auth0/resource_auth0_client_test.go index ff57f1d7..27b8ad46 100644 --- a/auth0/resource_auth0_client_test.go +++ b/auth0/resource_auth0_client_test.go @@ -6,11 +6,12 @@ import ( "strings" "testing" - "github.com/alexkappa/terraform-provider-auth0/auth0/internal/random" "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/alexkappa/terraform-provider-auth0/auth0/internal/random" + "gopkg.in/auth0.v5/management" ) @@ -379,6 +380,8 @@ func TestAccClientMobile(t *testing.T) { resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.0.android.0.app_package_name", "com.example"), resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.0.android.0.sha256_cert_fingerprints.#", "1"), resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.0.android.0.sha256_cert_fingerprints.0", "DE:AD:BE:EF"), + resource.TestCheckResourceAttr("auth0_client.my_client", "native_social_login.0.apple.0.enabled", "true"), + resource.TestCheckResourceAttr("auth0_client.my_client", "native_social_login.0.facebook.0.enabled", "false"), ), }, { @@ -387,6 +390,15 @@ func TestAccClientMobile(t *testing.T) { resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.0.android.#", "1"), resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.0.android.0.app_package_name", "com.example"), resource.TestCheckResourceAttr("auth0_client.my_client", "mobile.0.android.0.sha256_cert_fingerprints.#", "0"), + resource.TestCheckResourceAttr("auth0_client.my_client", "native_social_login.0.apple.0.enabled", "false"), + resource.TestCheckResourceAttr("auth0_client.my_client", "native_social_login.0.facebook.0.enabled", "true"), + ), + }, + { + // This just makes sure that you can change the type (where native_social_login cannot be set) + Config: random.Template(testAccClientConfigMobileUpdateNonMobile, rand), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("auth0_client.my_client", "app_type", "non_interactive"), ), }, }, @@ -397,11 +409,24 @@ const testAccClientConfigMobile = ` resource "auth0_client" "my_client" { name = "Acceptance Test - Mobile - {{.random}}" + app_type = "native" mobile { android { app_package_name = "com.example" sha256_cert_fingerprints = ["DE:AD:BE:EF"] } + ios { + team_id = "9JA89QQLNQ" + app_bundle_identifier = "com.my.bundle.id" + } + } + native_social_login { + apple { + enabled = true + } + facebook { + enabled = false + } } } ` @@ -410,11 +435,41 @@ const testAccClientConfigMobileUpdate = ` resource "auth0_client" "my_client" { name = "Acceptance Test - Mobile - {{.random}}" + app_type = "native" mobile { android { app_package_name = "com.example" sha256_cert_fingerprints = [] } + ios { + team_id = "1111111111" + app_bundle_identifier = "com.my.auth0.bundle" + } + } + native_social_login { + apple { + enabled = false + } + facebook { + enabled = true + } + } +} +` + +const testAccClientConfigMobileUpdateNonMobile = ` + +resource "auth0_client" "my_client" { + name = "Acceptance Test - Mobile - {{.random}}" + app_type = "non_interactive" + + native_social_login { + apple { + enabled = false + } + facebook { + enabled = false + } } } ` diff --git a/docs/resources/client.md b/docs/resources/client.md index bc6230be..ca6f99b0 100644 --- a/docs/resources/client.md +++ b/docs/resources/client.md @@ -115,6 +115,7 @@ Arguments accepted by this resource include: * `token_endpoint_auth_method` - (Optional) String. Defines the requested authentication method for the token endpoint. Options include `none` (public client without a client secret), `client_secret_post` (client uses HTTP POST parameters), `client_secret_basic` (client uses HTTP Basic). * `client_metadata` - (Optional) Map(String) * `mobile` - (Optional) List(Resource). Configuration settings for mobile native applications. For details, see [Mobile](#mobile). +* `native_social_login` - (Optional) List(Resource). Configuration settings to toggle native social login for mobile native applications. For details, see [Native Social Login](#native-social-login) ### JWT Configuration @@ -222,6 +223,26 @@ Arguments accepted by this resource include: * `team_id` - (Optional) String * `app_bundle_identifier` - (Optional) String +### Native Social Login + +> Note: once this is set it must stay set, with both resources set to "false" in order to change the app_type + +`native_social_login` supports the following arguments: + +* `apple` (Optional) Resource: +* `facebook` (Optional) Resources: + +#### Apple + +`apple` supports the following arguments: + +* `enabled` Boolean + +#### Facebook + +`facebook` supports the following arguments: + +* `enabled` Boolean ## Attribute Reference Attributes exported by this resource include: diff --git a/scripts/gendocs.go b/scripts/gendocs.go index e32409f1..b92a69e3 100644 --- a/scripts/gendocs.go +++ b/scripts/gendocs.go @@ -1,3 +1,4 @@ +//go:build ignore // +build ignore package main