forked from auth0/terraform-provider-auth0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support for
auth0_prompt_screen_partial
and `auth0_prompt_scree…
…n_partials` in Prompt Resources (auth0#1013) * Add-Support-for-Prompt-Screen-Partials * Add auth0_prompt_screen_partial Resource and Required Docs * Fix Linting * Updated Go-auth0 Version 1.9.0 to 1.10.0 * Added Testcases for other insertionpoints as well * Fixed Linting * Added More testcases * Correct depends on for datasource of prompt partials Signed-off-by: BryanLewis-AtOkta <[email protected]>
- Loading branch information
1 parent
feee8ba
commit ef20947
Showing
28 changed files
with
7,523 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
page_title: "Data Source: auth0_prompt_screen_partials" | ||
description: |- | ||
Data source to retrieve a specific Auth0 prompt screen partials by prompt_type. | ||
--- | ||
|
||
# Data Source: auth0_prompt_screen_partials | ||
|
||
Data source to retrieve a specific Auth0 prompt screen partials by `prompt_type`. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "auth0_prompt_screen_partials" "prompt_screen_partials" { | ||
prompt_type = "prompt-name" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `prompt_type` (String) The type of prompt to customize. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `screen_partials` (Block List) The screen partials associated with the prompt type. (see [below for nested schema](#nestedblock--screen_partials)) | ||
|
||
<a id="nestedblock--screen_partials"></a> | ||
### Nested Schema for `screen_partials` | ||
|
||
Read-Only: | ||
|
||
- `insertion_points` (List of Object) (see [below for nested schema](#nestedatt--screen_partials--insertion_points)) | ||
- `screen_name` (String) The name of the screen associated with the partials | ||
|
||
<a id="nestedatt--screen_partials--insertion_points"></a> | ||
### Nested Schema for `screen_partials.insertion_points` | ||
|
||
Read-Only: | ||
|
||
- `form_content_end` (String) | ||
- `form_content_start` (String) | ||
- `form_footer_end` (String) | ||
- `form_footer_start` (String) | ||
- `secondary_actions_end` (String) | ||
- `secondary_actions_start` (String) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
page_title: "Resource: auth0_prompt_screen_partial" | ||
description: |- | ||
With this resource, you can manage a customized sign up and login experience by adding custom content, form elements and css/javascript. You can read more about this here https://auth0.com/docs/customize/universal-login-pages/customize-signup-and-login-prompts. | ||
--- | ||
|
||
# Resource: auth0_prompt_screen_partial | ||
|
||
With this resource, you can manage a customized sign up and login experience by adding custom content, form elements and css/javascript. You can read more about this [here](https://auth0.com/docs/customize/universal-login-pages/customize-signup-and-login-prompts). | ||
|
||
!> This resource appends a specific prompt screen to the list of prompt screens displayed to the user during the authentication flow. | ||
In contrast, the `auth0_prompt_screen_partials` resource manages the complete set of prompt screens that are displayed during the | ||
authentication flow. To avoid potential issues, it is recommended not to use this resource in conjunction with the | ||
`auth0_prompt_screen_partials` resource when managing prompt screens for the same prompt. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "auth0_prompt_screen_partial" "login" { | ||
prompt_type = "login" | ||
screen_name = "login" | ||
insertion_points { | ||
form_content_start = "<div>Form Content Start</div>" | ||
form_content_end = "<div>Form Content End</div>" | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `prompt_type` (String) The prompt that you are adding partials for. Options are: `login-id`, `login`, `login-password`, `signup`, `signup-id`, `signup-password`, `login-passwordless`. | ||
- `screen_name` (String) The name of the screen associated with the partials | ||
|
||
### Optional | ||
|
||
- `insertion_points` (Block List, Max: 1) The insertion points for the partials. (see [below for nested schema](#nestedblock--insertion_points)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
<a id="nestedblock--insertion_points"></a> | ||
### Nested Schema for `insertion_points` | ||
|
||
Optional: | ||
|
||
- `form_content_end` (String) Content that goes at the end of the form. | ||
- `form_content_start` (String) Content that goes at the start of the form. | ||
- `form_footer_end` (String) Footer content for the end of the footer. | ||
- `form_footer_start` (String) Footer content for the start of the footer. | ||
- `secondary_actions_end` (String) Actions that go at the end of secondary actions. | ||
- `secondary_actions_start` (String) Actions that go at the start of secondary actions. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# This resource can be imported using the prompt name and screen_name. | ||
# | ||
# As this is not a resource identifiable by an ID within the Auth0 Management API, | ||
# login can be imported using the prompt name and screen name using the format: | ||
# prompt_name:screen_name | ||
# | ||
# Example: | ||
terraform import auth0_prompt_screen_partial.login "login:login" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
page_title: "Resource: auth0_prompt_screen_partials" | ||
description: |- | ||
With this resource, you can manage a customized sign up and login experience by adding custom content, form elements and css/javascript. You can read more about this here https://auth0.com/docs/customize/universal-login-pages/customize-signup-and-login-prompts. | ||
--- | ||
|
||
# Resource: auth0_prompt_screen_partials | ||
|
||
With this resource, you can manage a customized sign up and login experience by adding custom content, form elements and css/javascript. You can read more about this [here](https://auth0.com/docs/customize/universal-login-pages/customize-signup-and-login-prompts). | ||
|
||
!> This resource manages the entire set of prompt screens enabled for a prompt. In contrast, the `auth0_prompt_screen_partial` | ||
resource appends a specific prompt screen to the list of prompt screens displayed to the user during the authentication flow. | ||
To avoid potential issues, it is recommended not to use this resource in conjunction with the `auth0_prompt_screen_partial` | ||
resource when managing prompt screens for the same prompt. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "auth0_prompt_screen_partials" "prompt_screen_partials" { | ||
prompt_type = "login-passwordless" | ||
screen_partials { | ||
screen_name = "login-passwordless-email-code" | ||
insertion_points { | ||
form_content_start = "<div>Form Content Start</div>" | ||
form_content_end = "<div>Form Content End</div>" | ||
} | ||
} | ||
screen_partials { | ||
screen_name = "login-passwordless-sms-otp" | ||
insertion_points { | ||
form_content_start = "<div>Form Content Start</div>" | ||
form_content_end = "<div>Form Content End</div>" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `prompt_type` (String) The prompt that you are adding partials for. Options are: `login-id`, `login`, `login-password`, `signup`, `signup-id`, `signup-password`, `login-passwordless`. | ||
|
||
### Optional | ||
|
||
- `screen_partials` (Block List) (see [below for nested schema](#nestedblock--screen_partials)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
<a id="nestedblock--screen_partials"></a> | ||
### Nested Schema for `screen_partials` | ||
|
||
Required: | ||
|
||
- `insertion_points` (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--screen_partials--insertion_points)) | ||
- `screen_name` (String) The name of the screen associated with the partials | ||
|
||
<a id="nestedblock--screen_partials--insertion_points"></a> | ||
### Nested Schema for `screen_partials.insertion_points` | ||
|
||
Optional: | ||
|
||
- `form_content_end` (String) Content that goes at the end of the form. | ||
- `form_content_start` (String) Content that goes at the start of the form. | ||
- `form_footer_end` (String) Footer content for the end of the footer. | ||
- `form_footer_start` (String) Footer content for the start of the footer. | ||
- `secondary_actions_end` (String) Actions that go at the end of secondary actions. | ||
- `secondary_actions_start` (String) Actions that go at the start of secondary actions. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# This resource can be imported using the prompt name. | ||
# | ||
# Example: | ||
terraform import auth0_prompt_screen_partials.prompt_screen_partials "login-passwordless" | ||
``` |
3 changes: 3 additions & 0 deletions
3
examples/data-sources/auth0_prompt_screen_partials/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "auth0_prompt_screen_partials" "prompt_screen_partials" { | ||
prompt_type = "prompt-name" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This resource can be imported using the prompt name and screen_name. | ||
# | ||
# As this is not a resource identifiable by an ID within the Auth0 Management API, | ||
# login can be imported using the prompt name and screen name using the format: | ||
# prompt_name:screen_name | ||
# | ||
# Example: | ||
terraform import auth0_prompt_screen_partial.login "login:login" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "auth0_prompt_screen_partial" "login" { | ||
prompt_type = "login" | ||
screen_name = "login" | ||
insertion_points { | ||
form_content_start = "<div>Form Content Start</div>" | ||
form_content_end = "<div>Form Content End</div>" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This resource can be imported using the prompt name. | ||
# | ||
# Example: | ||
terraform import auth0_prompt_screen_partials.prompt_screen_partials "login-passwordless" |
19 changes: 19 additions & 0 deletions
19
examples/resources/auth0_prompt_screen_partials/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
resource "auth0_prompt_screen_partials" "prompt_screen_partials" { | ||
prompt_type = "login-passwordless" | ||
|
||
screen_partials { | ||
screen_name = "login-passwordless-email-code" | ||
insertion_points { | ||
form_content_start = "<div>Form Content Start</div>" | ||
form_content_end = "<div>Form Content End</div>" | ||
} | ||
} | ||
|
||
screen_partials { | ||
screen_name = "login-passwordless-sms-otp" | ||
insertion_points { | ||
form_content_start = "<div>Form Content Start</div>" | ||
form_content_end = "<div>Form Content End</div>" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package prompt | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/auth0/go-auth0/management" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
|
||
"github.com/auth0/terraform-provider-auth0/internal/config" | ||
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema" | ||
) | ||
|
||
// NewPromptScreenPartialsDataSource creates a new data source to retrieve a specific Auth0 prompt screen partials by `prompt_type`. | ||
func NewPromptScreenPartialsDataSource() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: readPromptScreenPartialsDataSource, | ||
Description: "Data source to retrieve a specific Auth0 prompt screen partials by `prompt_type`.", | ||
Schema: getScreenPartialsDataSourceSchema(), | ||
} | ||
} | ||
|
||
func getScreenPartialsDataSourceSchema() map[string]*schema.Schema { | ||
dataSourceSchema := internalSchema.TransformResourceToDataSource(NewScreenPartialsResource().Schema) | ||
internalSchema.SetExistingAttributesAsRequired(dataSourceSchema, "prompt_type") | ||
dataSourceSchema["prompt_type"].Description = "The type of prompt to customize." | ||
dataSourceSchema["prompt_type"].ValidateFunc = validation.StringInSlice(allowedPromptsWithPartials, false) | ||
dataSourceSchema["screen_partials"].Description = "The screen partials associated with the prompt type." | ||
dataSourceSchema["screen_partials"].Optional = true | ||
return dataSourceSchema | ||
} | ||
|
||
func readPromptScreenPartialsDataSource(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
api := meta.(*config.Config).GetAPI() | ||
|
||
promptType := data.Get("prompt_type").(string) | ||
screenPartials, err := api.Prompt.GetPartials(ctx, management.PromptType(promptType)) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
data.SetId(promptType) | ||
if err := flattenPromptScreenPartials(data, screenPartials); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
return diag.FromErr(err) | ||
} |
Oops, something went wrong.