Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow basic auth mode for VMC PCI use case #577

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions nsxt/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func Provider() *schema.Provider {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("NSXT_VMC_AUTH_MODE", "Default"),
ValidateFunc: validation.StringInSlice([]string{"Default", "Bearer"}, false),
ValidateFunc: validation.StringInSlice([]string{"Default", "Bearer", "Basic"}, false),
Description: "Mode for VMC authorization",
},
"enforcement_point": {
Expand Down Expand Up @@ -363,8 +363,11 @@ func configureNsxtClient(d *schema.ResourceData, clients *nsxtClients) error {
clientAuthCert := d.Get("client_auth_cert").(string)
clientAuthKey := d.Get("client_auth_key").(string)
vmcToken := d.Get("vmc_token").(string)
vmcAuthMode := d.Get("vmc_auth_mode").(string)

if len(vmcToken) > 0 {
if (len(vmcToken) > 0) || (vmcAuthMode == "Basic") {
// VMC can operate without token with basic auth, however MP API is not
// available for cloud admin user
return nil
}

Expand Down Expand Up @@ -644,7 +647,7 @@ func configurePolicyConnectorData(d *schema.ResourceData, clients *nsxtClients)
clients.PolicyEnforcementPoint = policyEnforcementPoint
clients.PolicyGlobalManager = policyGlobalManager

if len(vmcAccessToken) > 0 {
if (len(vmcAccessToken) > 0) || (vmcAuthMode == "Basic") {
// Special treatment for VMC since MP API is not available there
initNSXVersionVMC(*clients)
}
Expand Down