Skip to content

Commit 545d1be

Browse files
authored
fix: ignore masked smtp pass in auth config (#157)
1 parent fa4e311 commit 545d1be

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/provider/settings_resource.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ func readAuthConfig(ctx context.Context, state *SettingsResourceModel, client *a
312312
msg := fmt.Sprintf("Unable to read auth settings, got status %d: %s", httpResp.StatusCode(), httpResp.Body)
313313
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
314314
}
315+
// API treats sensitive fields as write-only
316+
var body api.AuthConfigResponse
317+
if !state.Auth.IsNull() {
318+
if diags := state.Auth.Unmarshal(&body); diags.HasError() {
319+
return diags
320+
}
321+
}
322+
httpResp.JSON200.SmtpPass = body.SmtpPass
315323
if state.Auth, err = parseConfig(state.Auth, *httpResp.JSON200); err != nil {
316324
msg := fmt.Sprintf("Unable to read auth settings, got error: %s", err)
317325
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -334,6 +342,8 @@ func updateAuthConfig(ctx context.Context, plan *SettingsResourceModel, client *
334342
msg := fmt.Sprintf("Unable to update auth settings, got status %d: %s", httpResp.StatusCode(), httpResp.Body)
335343
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
336344
}
345+
// Copy over sensitive fields from TF plan
346+
httpResp.JSON200.SmtpPass = body.SmtpPass
337347

338348
if plan.Auth, err = parseConfig(plan.Auth, *httpResp.JSON200); err != nil {
339349
msg := fmt.Sprintf("Unable to update auth settings, got error: %s", err)

0 commit comments

Comments
 (0)