Skip to content

Commit

Permalink
Update based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jul 7, 2023
1 parent be77795 commit d1054ff
Show file tree
Hide file tree
Showing 5 changed files with 509 additions and 82 deletions.
55 changes: 44 additions & 11 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ automated workflows before upgrading.

### Deprecations

- [Auth0 Pages](#auth0-pages)
- [Auth0 Global Client](#auth0-global-client)
- [Auth0 Tenant Pages](#auth0-tenant-pages)

#### Auth0 Pages
#### Auth0 Global Client

The `auth0_global_client` resource and data source were introduced primarily to allow managing the `custom_login_page`
and `custom_login_page_on` attributes in order to manage the custom login page of a tenant. These are now deprecated in
favour of the `auth0_pages` resource.

The `custom_login_page` on the `auth0_global_client` and the `change_password`, `guardian_mfa_page` and `error_page`
fields on the `auth0_tenant` have been deprecated in favour of managing them on a brand new `auth0_pages` resource.
To ensure a smooth transition when we eventually remove the capability to manage the custom
Auth0 pages through the `auth0_global_client` and `auth0_tenant` resources, we recommend proactively migrating to the
newly introduced `auth0_pages` resource. This will help you stay prepared for future changes.
login page through the `auth0_global_client`, we recommend proactively migrating to the `auth0_pages` resource.
This will help you stay prepared for future changes.

<table>
<tr>
Expand All @@ -30,7 +33,42 @@ resource "auth0_global_client" "global" {
custom_login_page_on = true
custom_login_page = "<html>My Custom Login Page</html>"
}
```

</td>
<td>

```terraform
resource "auth0_pages" "my_pages" {
login {
enabled = true
html = "<html><body>My Custom Login Page</body></html>"
}
}
```

</td>
</tr>
</table>

#### Auth0 Tenant Pages

The `change_password`, `guardian_mfa_page` and `error_page` attributes on the `auth0_tenant` have been deprecated in
favour of managing them with the `auth0_pages` resource.

To ensure a smooth transition when we eventually remove the capability to manage these custom Auth0 pages through the
`auth0_tenant` resource, we recommend proactively migrating to the `auth0_pages` resource. This will help you stay
prepared for future changes.

<table>
<tr>
<th>Before (v0.49.0)</th>
<th>After (v0.50.0)</th>
</tr>
<tr>
<td>

```terraform
resource "auth0_tenant" "my_tenant" {
change_password {
enabled = true
Expand All @@ -55,11 +93,6 @@ resource "auth0_tenant" "my_tenant" {

```terraform
resource "auth0_pages" "my_pages" {
login {
enabled = true
html = "<html><body>My Custom Login Page</body></html>"
}
change_password {
enabled = true
html = "<html><body>My Custom Reset Password Page</body></html>"
Expand Down
11 changes: 6 additions & 5 deletions internal/auth0/page/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewResource() *schema.Resource {
"enabled": {
Type: schema.TypeBool,
Required: true,
Description: "Indicates whether to use the custom Login page HTML (`true`) or the default Auth0 page (`false`). Defaults to `false`.",
Description: "Indicates whether to use the custom Login page HTML (`true`) or the default Auth0 page (`false`).",
},
"html": {
Type: schema.TypeString,
Expand All @@ -62,7 +62,7 @@ func NewResource() *schema.Resource {
"enabled": {
Type: schema.TypeBool,
Required: true,
Description: "Indicates whether to use the custom Reset Password HTML (`true`) or the default Auth0 page (`false`). Defaults to `false`.",
Description: "Indicates whether to use the custom Reset Password HTML (`true`) or the default Auth0 page (`false`).",
},
"html": {
Type: schema.TypeString,
Expand All @@ -84,7 +84,7 @@ func NewResource() *schema.Resource {
"enabled": {
Type: schema.TypeBool,
Required: true,
Description: "Indicates whether to use the custom Guardian MFA HTML (`true`) or the default Auth0 page (`false`). Defaults to `false`.",
Description: "Indicates whether to use the custom Guardian MFA HTML (`true`) or the default Auth0 page (`false`).",
},
"html": {
Type: schema.TypeString,
Expand All @@ -105,14 +105,14 @@ func NewResource() *schema.Resource {
Schema: map[string]*schema.Schema{
"html": {
Type: schema.TypeString,
Required: true,
Optional: true,
Description: "Customized content for the Error page. " +
"HTML format with supported [Liquid syntax](https://github.com/Shopify/liquid/wiki/Liquid-for-Designers).",
},
"show_log_link": {
Type: schema.TypeBool,
Required: true,
Description: "Indicates whether to show the link to logs as part of the default error page. Defaults to `true`.",
Description: "Indicates whether to show the link to logs as part of the default error page.",
},
"url": {
Type: schema.TypeString,
Expand Down Expand Up @@ -204,6 +204,7 @@ func deletePages(_ context.Context, _ *schema.ResourceData, meta interface{}) di
ErrorPage: &management.TenantErrorPage{
ShowLogLink: auth0.Bool(false),
URL: auth0.String(""),
HTML: auth0.String(""),
},
GuardianMFAPage: &management.TenantGuardianMFAPage{
Enabled: auth0.Bool(false),
Expand Down
33 changes: 33 additions & 0 deletions internal/auth0/page/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ const testAccPagesWithNoOptionalBlocksWillNotModifyPreExistingChanges = `
resource "auth0_pages" "my_pages" { }
`

const testAccPagesUpdateOnlyWithCustomLoginAndErrorPages = `
resource "auth0_pages" "my_pages" {
login {
enabled = true
html = "<html><body>My Custom Login Page</body></html>"
}
error {
show_log_link = true
html = "<html><body>My Custom Error Page</body></html>"
url = "https://example.com"
}
}
`

func TestAccPages(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -101,6 +116,24 @@ func TestAccPages(t *testing.T) {
resource.TestCheckResourceAttr("auth0_pages.my_pages", "error.0.url", ""),
),
},
{
Config: acctest.ParseTestName(testAccPagesUpdateOnlyWithCustomLoginAndErrorPages, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_pages.my_pages", "login.#", "1"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "login.0.enabled", "true"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "login.0.html", "<html><body>My Custom Login Page</body></html>"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "change_password.#", "1"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "change_password.0.enabled", "false"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "change_password.0.html", ""),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "guardian_mfa.#", "1"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "guardian_mfa.0.enabled", "false"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "guardian_mfa.0.html", ""),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "error.#", "1"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "error.0.show_log_link", "true"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "error.0.html", "<html><body>My Custom Error Page</body></html>"),
resource.TestCheckResourceAttr("auth0_pages.my_pages", "error.0.url", "https://example.com"),
),
},
{
Config: acctest.ParseTestName(testAccPagesCreate, t.Name()),
},
Expand Down
2 changes: 1 addition & 1 deletion internal/auth0/tenant/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func NewResource() *schema.Resource {

func createTenant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
d.SetId(id.UniqueId())
return readTenant(ctx, d, m)
return updateTenant(ctx, d, m)
}

func readTenant(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Expand Down
Loading

0 comments on commit d1054ff

Please sign in to comment.