Skip to content

Commit

Permalink
Escape password when requesting for session token
Browse files Browse the repository at this point in the history
When NSX password contains certain special characters(such as &),
those need to be encoded when sent to session/create API

Signed-off-by: Anna Khmelnitsky <[email protected]>
  • Loading branch information
annakhm committed May 29, 2024
1 parent f860e88 commit ca4f98c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nsxt/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"math/rand"
"net/http"
"net/http/httputil"
"net/url"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -554,6 +555,12 @@ func configureNsxtClient(d *schema.ResourceData, clients *nsxtClients) error {
username := d.Get("username").(string)
password := d.Get("password").(string)

// The correct place to escape special chars would be inside the SDK
// However since the SDK is deprecated, we implement escaping here
// TODO implement this functionality with new mp-sdk
username = url.QueryEscape(username)
password = url.QueryEscape(password)

if needCreds {
if username == "" {
return fmt.Errorf("username must be provided")
Expand Down

0 comments on commit ca4f98c

Please sign in to comment.