Skip to content

Commit

Permalink
[PLAT-8028][YBA Terraform]Do not store API token in YBA
Browse files Browse the repository at this point in the history
Summary:
The API token returned by the Session Management APIs are now masked. The token is only available
through the `/api_token` endpoint which is now used here

Test Plan: Connected to local YBA and tested normal workflows

Reviewers: sneelakantan, nbhatia, skurapati, vpatibandla

Reviewed By: sneelakantan

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D35261
  • Loading branch information
Deepti-yb committed May 31, 2024
1 parent fc36562 commit ef8c2cd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
github.com/yugabyte/platform-go-client v0.0.0-20240415070755-794cd3b15b89
github.com/yugabyte/platform-go-client v0.0.0-20240527085424-58f874756dfd
golang.org/x/crypto v0.18.0
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6e
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/yugabyte/platform-go-client v0.0.0-20240415070755-794cd3b15b89 h1:h1r9J3GzgfpVtm7iX0z3yEA12Wg5oO04z5XEtf5ZpzA=
github.com/yugabyte/platform-go-client v0.0.0-20240415070755-794cd3b15b89/go.mod h1:ZErtCh7Ig1QkNpWuGQ5YtaEJvD4fKdDS+iQxJfIlGMQ=
github.com/yugabyte/platform-go-client v0.0.0-20240527085424-58f874756dfd h1:SUXmrXZZJiIBEgJRruM5dHAAEjNU8AyPwi5SRbv57BA=
github.com/yugabyte/platform-go-client v0.0.0-20240527085424-58f874756dfd/go.mod h1:ZErtCh7Ig1QkNpWuGQ5YtaEJvD4fKdDS+iQxJfIlGMQ=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
2 changes: 1 addition & 1 deletion internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type APIClient struct {
}

// NewAPIClient creates a wrapper for public and non-public APIs
func NewAPIClient(enableHTTPS bool, host string, apiKey string) (*APIClient, error) {
func NewAPIClient(enableHTTPS bool, host, apiKey string) (*APIClient, error) {
// create swagger go client
cfg := client.NewConfiguration()
cfg.Host = host
Expand Down
4 changes: 2 additions & 2 deletions internal/customer/resource_customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func resourceCustomerCreate(

token := ""
if r.ApiToken != nil {
token = *r.ApiToken
token = r.GetApiToken()
}
if err = d.Set("api_token", token); err != nil {
return diag.FromErr(err)
Expand Down Expand Up @@ -179,7 +179,7 @@ func resourceCustomerRead(
return diag.FromErr(errMessage)
}

if err = d.Set("api_token", *r.ApiToken); err != nil {
if err = d.Set("api_token", apiKey); err != nil {
return diag.FromErr(err)
}
if err = d.Set("cuuid", *r.CustomerUUID); err != nil {
Expand Down

0 comments on commit ef8c2cd

Please sign in to comment.