Skip to content

Commit

Permalink
fix: ignore masked smtp pass in auth config (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge authored Sep 17, 2024
1 parent fa4e311 commit 545d1be
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/provider/settings_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ func readAuthConfig(ctx context.Context, state *SettingsResourceModel, client *a
msg := fmt.Sprintf("Unable to read auth settings, got status %d: %s", httpResp.StatusCode(), httpResp.Body)
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
}
// API treats sensitive fields as write-only
var body api.AuthConfigResponse
if !state.Auth.IsNull() {
if diags := state.Auth.Unmarshal(&body); diags.HasError() {
return diags
}
}
httpResp.JSON200.SmtpPass = body.SmtpPass
if state.Auth, err = parseConfig(state.Auth, *httpResp.JSON200); err != nil {
msg := fmt.Sprintf("Unable to read auth settings, got error: %s", err)
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
Expand All @@ -334,6 +342,8 @@ func updateAuthConfig(ctx context.Context, plan *SettingsResourceModel, client *
msg := fmt.Sprintf("Unable to update auth settings, got status %d: %s", httpResp.StatusCode(), httpResp.Body)
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
}
// Copy over sensitive fields from TF plan
httpResp.JSON200.SmtpPass = body.SmtpPass

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

0 comments on commit 545d1be

Please sign in to comment.