Skip to content

Commit 979c623

Browse files
GH-2189 | OKTA-1087655 | Changes To Update Okta Default Brand's help_url (#2607)
* GH-2189 | OKTA-1087655 | Changes To Update Okta Default Brand's help_url
1 parent 13fbbec commit 979c623

8 files changed

Lines changed: 604 additions & 352 deletions

File tree

examples/resources/okta_customized_signin_page/basic.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ resource "okta_customized_signin_page" "test" {
1111
widget_generation = "G2"
1212
}
1313
}
14+
15+
16+
resource "okta_customized_signin_page" "test-2" {
17+
brand_id = "bndnkw1sc3flIOTF51d7"
18+
widget_customizations {
19+
widget_generation = "G3"
20+
help_url = "https://helpurltest.com"
21+
help_label = "Help URL Test"
22+
}
23+
}

examples/resources/okta_customized_signin_page/update.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ resource "okta_customized_signin_page" "test" {
1717
}
1818
}
1919

20+
21+
resource "okta_customized_signin_page" "test-2" {
22+
brand_id = "bndnkw1sc3flIOTF51d7"
23+
widget_customizations {
24+
widget_generation = "G3"
25+
help_url = "https://helpurltestupdated.com"
26+
help_label = "Help URL Test Updated"
27+
custom_link_1_url = "https://customlink1url.com"
28+
custom_link_1_label = "Custom Link 1 URL"
29+
}
30+
}

okta/resources/resources.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ const (
135135
OktaIDaaSDevice = "okta_device"
136136
OktaIDaaSHookKey = "okta_hook_key"
137137
OktaIDaaSUISchema = "okta_ui_schema"
138+
OktaIDaaSCustomizedSignInPage = "okta_customized_signin_page"
138139
OktaGovernanceCampaign = "okta_campaign"
139140
OktaGovernanceEntitlement = "okta_entitlement"
140141
OktaGovernanceEntitlementBundle = "okta_entitlement_bundle"

okta/services/idaas/customization.go

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,40 +111,42 @@ func mapSignInPageToState(ctx context.Context, data *okta.SignInPage, state *sig
111111

112112
func buildSignInPageRequest(ctx context.Context, model signinPageModel) (okta.SignInPage, diag.Diagnostics) {
113113
sp := okta.SignInPage{}
114-
sp.SetPageContent(model.PageContent.ValueString())
115-
sp.SetWidgetVersion(model.WidgetVersion.ValueString())
114+
if !model.PageContent.IsNull() {
115+
sp.SetPageContent(model.PageContent.ValueString())
116+
}
116117

117118
if !model.WidgetVersion.IsNull() {
118-
wc := okta.SignInPageAllOfWidgetCustomizations{}
119-
wcm := &widgetCustomizationsModel{}
120-
diags := model.WidgetCustomizations.As(ctx, wcm, basetypes.ObjectAsOptions{})
121-
if diags.HasError() {
122-
return *okta.NewSignInPage(), diags
123-
}
124-
wc.SignInLabel = wcm.SignInLabel.ValueStringPointer()
125-
wc.UsernameLabel = wcm.UsernameLabel.ValueStringPointer()
126-
wc.UsernameInfoTip = wcm.UsernameInfoTip.ValueStringPointer()
127-
wc.PasswordLabel = wcm.PasswordLabel.ValueStringPointer()
128-
wc.PasswordInfoTip = wcm.PasswordInfoTip.ValueStringPointer()
129-
wc.ShowPasswordVisibilityToggle = wcm.ShowPasswordVisibilityToggle.ValueBoolPointer()
130-
wc.ShowUserIdentifier = wcm.ShowUserIdentifier.ValueBoolPointer()
131-
wc.ForgotPasswordLabel = wcm.ForgotPasswordLabel.ValueStringPointer()
132-
wc.ForgotPasswordUrl = wcm.ForgotPasswordURL.ValueStringPointer()
133-
wc.UnlockAccountLabel = wcm.UnlockAccountLabel.ValueStringPointer()
134-
wc.UnlockAccountUrl = wcm.UnlockAccountURL.ValueStringPointer()
135-
wc.HelpLabel = wcm.HelpLabel.ValueStringPointer()
136-
wc.HelpUrl = wcm.HelpURL.ValueStringPointer()
137-
wc.CustomLink1Label = wcm.CustomLink1Label.ValueStringPointer()
138-
wc.CustomLink1Url = wcm.CustomLink1URL.ValueStringPointer()
139-
wc.CustomLink2Label = wcm.CustomLink2Label.ValueStringPointer()
140-
wc.CustomLink2Url = wcm.CustomLink2URL.ValueStringPointer()
141-
wc.AuthenticatorPageCustomLinkLabel = wcm.AuthenticatorPageCustomLinkLabel.ValueStringPointer()
142-
wc.AuthenticatorPageCustomLinkUrl = wcm.AuthenticatorPageCustomLinkURL.ValueStringPointer()
143-
wc.ClassicRecoveryFlowEmailOrUsernameLabel = wcm.ClassicRecoveryFlowEmailOrUsernameLabel.ValueStringPointer()
144-
wc.SetWidgetGeneration(wcm.WidgetGeneration.ValueString())
119+
sp.SetWidgetVersion(model.WidgetVersion.ValueString())
120+
}
145121

146-
sp.SetWidgetCustomizations(wc)
122+
wc := okta.SignInPageAllOfWidgetCustomizations{}
123+
wcm := &widgetCustomizationsModel{}
124+
diags := model.WidgetCustomizations.As(ctx, wcm, basetypes.ObjectAsOptions{})
125+
if diags.HasError() {
126+
return *okta.NewSignInPage(), diags
147127
}
128+
wc.SignInLabel = wcm.SignInLabel.ValueStringPointer()
129+
wc.UsernameLabel = wcm.UsernameLabel.ValueStringPointer()
130+
wc.UsernameInfoTip = wcm.UsernameInfoTip.ValueStringPointer()
131+
wc.PasswordLabel = wcm.PasswordLabel.ValueStringPointer()
132+
wc.PasswordInfoTip = wcm.PasswordInfoTip.ValueStringPointer()
133+
wc.ShowPasswordVisibilityToggle = wcm.ShowPasswordVisibilityToggle.ValueBoolPointer()
134+
wc.ShowUserIdentifier = wcm.ShowUserIdentifier.ValueBoolPointer()
135+
wc.ForgotPasswordLabel = wcm.ForgotPasswordLabel.ValueStringPointer()
136+
wc.ForgotPasswordUrl = wcm.ForgotPasswordURL.ValueStringPointer()
137+
wc.UnlockAccountLabel = wcm.UnlockAccountLabel.ValueStringPointer()
138+
wc.UnlockAccountUrl = wcm.UnlockAccountURL.ValueStringPointer()
139+
wc.HelpLabel = wcm.HelpLabel.ValueStringPointer()
140+
wc.HelpUrl = wcm.HelpURL.ValueStringPointer()
141+
wc.CustomLink1Label = wcm.CustomLink1Label.ValueStringPointer()
142+
wc.CustomLink1Url = wcm.CustomLink1URL.ValueStringPointer()
143+
wc.CustomLink2Label = wcm.CustomLink2Label.ValueStringPointer()
144+
wc.CustomLink2Url = wcm.CustomLink2URL.ValueStringPointer()
145+
wc.AuthenticatorPageCustomLinkLabel = wcm.AuthenticatorPageCustomLinkLabel.ValueStringPointer()
146+
wc.AuthenticatorPageCustomLinkUrl = wcm.AuthenticatorPageCustomLinkURL.ValueStringPointer()
147+
wc.ClassicRecoveryFlowEmailOrUsernameLabel = wcm.ClassicRecoveryFlowEmailOrUsernameLabel.ValueStringPointer()
148+
wc.SetWidgetGeneration(wcm.WidgetGeneration.ValueString())
149+
sp.SetWidgetCustomizations(wc)
148150

149151
if !model.ContentSecurityPolicySetting.IsNull() {
150152
csp := okta.ContentSecurityPolicySetting{}

okta/services/idaas/resource_okta_customized_signin_page.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66

77
"github.com/hashicorp/terraform-plugin-framework/path"
88
"github.com/hashicorp/terraform-plugin-framework/resource"
9+
resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
910
"github.com/okta/terraform-provider-okta/okta/config"
11+
"github.com/okta/terraform-provider-okta/okta/resources"
1012
)
1113

1214
// Ensure the implementation satisfies the expected interfaces.
@@ -30,6 +32,14 @@ func (r *customizedSigninPageResource) Metadata(_ context.Context, req resource.
3032

3133
func (r *customizedSigninPageResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
3234
newSchema := resourceSignInSchema
35+
pageContentAttribute := newSchema.Attributes["page_content"].(resourceSchema.StringAttribute)
36+
pageContentAttribute.Required = false
37+
pageContentAttribute.Optional = true
38+
newSchema.Attributes["page_content"] = pageContentAttribute
39+
widgetVersionAttribute := newSchema.Attributes["widget_version"].(resourceSchema.StringAttribute)
40+
widgetVersionAttribute.Required = false
41+
widgetVersionAttribute.Optional = true
42+
newSchema.Attributes["widget_version"] = widgetVersionAttribute
3343
newSchema.Description = "Manage the customized signin page of a brand"
3444
resp.Schema = newSchema
3545
}
@@ -40,6 +50,10 @@ func (r *customizedSigninPageResource) Configure(_ context.Context, req resource
4050
}
4151

4252
func (r *customizedSigninPageResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
53+
54+
oktaMutexKV.Lock(resources.OktaIDaaSCustomizedSignInPage)
55+
defer oktaMutexKV.Unlock(resources.OktaIDaaSCustomizedSignInPage)
56+
4357
var state signinPageModel
4458
resp.Diagnostics.Append(req.Plan.Get(ctx, &state)...)
4559
if resp.Diagnostics.HasError() {
@@ -103,6 +117,10 @@ func (r *customizedSigninPageResource) Read(ctx context.Context, req resource.Re
103117
}
104118

105119
func (r *customizedSigninPageResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
120+
121+
oktaMutexKV.Lock(resources.OktaIDaaSCustomizedSignInPage)
122+
defer oktaMutexKV.Unlock(resources.OktaIDaaSCustomizedSignInPage)
123+
106124
var state signinPageModel
107125
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
108126
if resp.Diagnostics.HasError() {
@@ -120,6 +138,10 @@ func (r *customizedSigninPageResource) Delete(ctx context.Context, req resource.
120138
}
121139

122140
func (r *customizedSigninPageResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
141+
142+
oktaMutexKV.Lock(resources.OktaIDaaSCustomizedSignInPage)
143+
defer oktaMutexKV.Unlock(resources.OktaIDaaSCustomizedSignInPage)
144+
123145
var state signinPageModel
124146
resp.Diagnostics.Append(req.Plan.Get(ctx, &state)...)
125147
if resp.Diagnostics.HasError() {

okta/services/idaas/resource_okta_customized_signin_page_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ func TestAccResourceOktaCustomizedSignInPage_crud(t *testing.T) {
2323
resource.TestCheckResourceAttr("okta_customized_signin_page.test", "widget_version", "^6"),
2424
resource.TestCheckResourceAttr("okta_customized_signin_page.test", "widget_customizations.widget_generation", "G2"),
2525
resource.TestCheckNoResourceAttr("okta_customized_signin_page.test", "content_security_policy_setting"),
26+
resource.TestCheckResourceAttr("okta_customized_signin_page.test-2", "widget_customizations.help_url", "https://helpurltest.com"),
27+
resource.TestCheckResourceAttr("okta_customized_signin_page.test-2", "widget_customizations.help_label", "Help URL Test"),
2628
),
2729
},
2830
{
@@ -34,6 +36,10 @@ func TestAccResourceOktaCustomizedSignInPage_crud(t *testing.T) {
3436
resource.TestCheckResourceAttr("okta_customized_signin_page.test", "content_security_policy_setting.mode", "report_only"),
3537
resource.TestCheckResourceAttr("okta_customized_signin_page.test", "content_security_policy_setting.report_uri", ""),
3638
resource.TestCheckResourceAttr("okta_customized_signin_page.test", "content_security_policy_setting.src_list.#", "2"),
39+
resource.TestCheckResourceAttr("okta_customized_signin_page.test-2", "widget_customizations.help_url", "https://helpurltestupdated.com"),
40+
resource.TestCheckResourceAttr("okta_customized_signin_page.test-2", "widget_customizations.help_label", "Help URL Test Updated"),
41+
resource.TestCheckResourceAttr("okta_customized_signin_page.test-2", "widget_customizations.custom_link_1_url", "https://customlink1url.com"),
42+
resource.TestCheckResourceAttr("okta_customized_signin_page.test-2", "widget_customizations.custom_link_1_label", "Custom Link 1 URL"),
3743
),
3844
},
3945
},

0 commit comments

Comments
 (0)