-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* SSO v2 changes * naming fixes * Dummy commit * Updated go mod * updated recording * Updated var name to fix lint issue * Added example for auth0_self_service_profile_custom_text * Added docs and examples * Updated docs * Updates * Addressed review comments
- Loading branch information
1 parent
de227d1
commit ec2597c
Showing
21 changed files
with
1,469 additions
and
132 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
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,51 @@ | ||
--- | ||
page_title: "Resource: auth0_self_service_profile_custom_text" | ||
description: |- | ||
With this resource, you can set custom text for Self-Service Profile | ||
--- | ||
|
||
# Resource: auth0_self_service_profile_custom_text | ||
|
||
With this resource, you can set custom text for Self-Service Profile | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "auth0_self_service_profile_custom_text" "sso_custom_text" { | ||
sso_id = "some-sso-id" | ||
language = "en" | ||
page = "get-started" | ||
body = jsonencode( | ||
{ | ||
"introduction" : "Welcome! With only a few steps you'll be able to setup your new custom text." | ||
} | ||
) | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `body` (String) The list of text keys and values to customize the self-service SSO page. Values can be plain text or rich HTML content limited to basic styling tags and hyperlinks | ||
- `language` (String) The language of the custom text | ||
- `page` (String) The page where the custom text is shown | ||
- `sso_id` (String) The id of the self-service profile | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# This resource can be imported by specifying the | ||
# sso-profile-id, language and page separated by "::" (note the double colon) | ||
# <sso-profile-id>::<language>::<page> | ||
# | ||
# Example | ||
terraform import auth0_self_service_profile_custom_text.example "some-sso-id::en::get-started" | ||
``` |
6 changes: 6 additions & 0 deletions
6
examples/resources/auth0_self_service_profile_custom_text/import.sh
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,6 @@ | ||
# This resource can be imported by specifying the | ||
# sso-profile-id, language and page separated by "::" (note the double colon) | ||
# <sso-profile-id>::<language>::<page> | ||
# | ||
# Example | ||
terraform import auth0_self_service_profile_custom_text.example "some-sso-id::en::get-started" |
11 changes: 11 additions & 0 deletions
11
examples/resources/auth0_self_service_profile_custom_text/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,11 @@ | ||
resource "auth0_self_service_profile_custom_text" "sso_custom_text" { | ||
sso_id = "some-sso-id" | ||
language = "en" | ||
page = "get-started" | ||
body = jsonencode( | ||
{ | ||
"introduction" : "Welcome! With only a few steps you'll be able to setup your new custom text." | ||
} | ||
) | ||
} | ||
|
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
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
111 changes: 111 additions & 0 deletions
111
internal/auth0/selfserviceprofile/resource_custom_text.go
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,111 @@ | ||
package selfserviceprofile | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
"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/structure" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
|
||
"github.com/auth0/terraform-provider-auth0/internal/config" | ||
internalError "github.com/auth0/terraform-provider-auth0/internal/error" | ||
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema" | ||
) | ||
|
||
// NewCustomTextResource will return a new auth0_self_service_profile_custom_text resource. | ||
func NewCustomTextResource() *schema.Resource { | ||
return &schema.Resource{ | ||
CreateContext: createCustomTextForSSOProfile, | ||
ReadContext: readCustomTextForSSOProfile, | ||
UpdateContext: updateCustomTextForSSOProfile, | ||
DeleteContext: deleteCustomTextForSSOProfile, | ||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
Description: "With this resource, you can set custom text for Self-Service Profile", | ||
Schema: map[string]*schema.Schema{ | ||
"sso_id": { | ||
Type: schema.TypeString, | ||
ForceNew: true, | ||
Required: true, | ||
Description: "The id of the self-service profile", | ||
}, | ||
"language": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The language of the custom text", | ||
}, | ||
"page": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The page where the custom text is shown", | ||
}, | ||
"body": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ValidateFunc: validation.StringIsJSON, | ||
DiffSuppressFunc: structure.SuppressJsonDiff, | ||
Description: "The list of text keys and values to customize the self-service SSO page. " + | ||
"Values can be plain text or rich HTML content limited to basic styling tags and hyperlinks", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func createCustomTextForSSOProfile(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
id := data.Get("sso_id").(string) | ||
language := data.Get("language").(string) | ||
page := data.Get("page").(string) | ||
|
||
internalSchema.SetResourceGroupID(data, id, language, page) | ||
|
||
return updateCustomTextForSSOProfile(ctx, data, meta) | ||
} | ||
|
||
func readCustomTextForSSOProfile(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
api := meta.(*config.Config).GetAPI() | ||
|
||
customText, err := api.SelfServiceProfile.GetCustomText(ctx, | ||
data.Get("sso_id").(string), | ||
data.Get("language").(string), | ||
data.Get("page").(string)) | ||
if err != nil { | ||
return diag.FromErr(internalError.HandleAPIError(data, err)) | ||
} | ||
|
||
return diag.FromErr(flattenSSOCustomText(data, customText)) | ||
} | ||
|
||
func updateCustomTextForSSOProfile(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
api := meta.(*config.Config).GetAPI() | ||
|
||
id := data.Get("sso_id").(string) | ||
language := data.Get("language").(string) | ||
page := data.Get("page").(string) | ||
body := data.Get("body").(string) | ||
|
||
if body == "" { | ||
return nil | ||
} | ||
|
||
var payload map[string]interface{} | ||
if err := json.Unmarshal([]byte(body), &payload); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
if err := api.SelfServiceProfile.SetCustomText(ctx, id, language, page, payload); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
return readCustomTextForSSOProfile(ctx, data, meta) | ||
} | ||
|
||
func deleteCustomTextForSSOProfile(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
if err := data.Set("body", "{}"); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
return updateCustomTextForSSOProfile(ctx, data, meta) | ||
} |
Oops, something went wrong.