Skip to content

Commit bdbf549

Browse files
authored
Fix overwriting Passcode (#167)
Fix overwriting `Passcode` What this PR does / why we need it Remove reading passcode from OS_PASSCODE in Authenticate Add passing Passcode through all credentials loading process Which issue this PR fixes Fix #166 Special notes for your reviewer Reviewed-by: Rodion Gyrbu <fpsoff@outlook.com> Reviewed-by: None <None> Reviewed-by: Anton Sidelnikov <None>
1 parent ec66f89 commit bdbf549

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

openstack/client.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package openstack
33
import (
44
"fmt"
55
"net/url"
6-
"os"
76
"reflect"
87
"regexp"
98
"strings"
@@ -113,8 +112,6 @@ func Authenticate(client *golangsdk.ProviderClient, options golangsdk.AuthOption
113112
if isTokenAuthOptions {
114113
switch chosen.ID {
115114
case v3:
116-
authOptions.Passcode = os.Getenv("OS_PASSCODE")
117-
118115
if authOptions.AgencyDomainName != "" && authOptions.AgencyName != "" {
119116
return v3authWithAgency(client, endpoint, &authOptions, golangsdk.EndpointOpts{})
120117
}

openstack/loader.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (e *Env) cloudFromEnv() *Cloud {
129129
Username: authOpts.Username,
130130
UserID: authOpts.UserID,
131131
Password: authOpts.Password,
132+
Passcode: authOpts.Passcode,
132133
ProjectName: authOpts.TenantName,
133134
ProjectID: authOpts.TenantID,
134135
UserDomainName: e.GetEnv("USER_DOMAIN_NAME"),
@@ -203,6 +204,9 @@ type AuthInfo struct {
203204
// Password is the password of the user.
204205
Password string `yaml:"password,omitempty" json:"password,omitempty"`
205206

207+
// Passcode for MFA.
208+
Passcode string `yaml:"-" json:"-"`
209+
206210
// ProjectName is the common/human-readable name of a project.
207211
// Users can be scoped to a project.
208212
// ProjectName on its own is not enough to ensure a unique scope. It must
@@ -610,6 +614,7 @@ func AuthOptionsFromInfo(authInfo *AuthInfo, authType AuthType) (golangsdk.AuthO
610614
DomainName: authInfo.DomainName,
611615
TenantID: authInfo.ProjectID,
612616
TenantName: authInfo.ProjectName,
617+
Passcode: authInfo.Passcode,
613618
}
614619

615620
explicitAuthType := getAuthType(authType)

0 commit comments

Comments
 (0)