Skip to content

Commit 6bb4126

Browse files
committed
access: prevent login with username-password when using wrong keys
Fixes apache#168 Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 79f09fb commit 6bb4126

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmd/network.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
211211

212212
var encodedParams string
213213
var err error
214+
usingApiKeySecretKey := false
214215

215216
if len(r.Config.ActiveProfile.APIKey) > 0 && len(r.Config.ActiveProfile.SecretKey) > 0 {
216217
apiKey := r.Config.ActiveProfile.APIKey
@@ -230,7 +231,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
230231
encodedParams = encodedParams + fmt.Sprintf("&signature=%s", url.QueryEscape(signature))
231232
params = nil
232233
}
233-
234+
usingApiKeySecretKey = true
234235
} else if len(r.Config.ActiveProfile.Username) > 0 && len(r.Config.ActiveProfile.Password) > 0 {
235236
sessionKey, err := Login(r)
236237
if err != nil {
@@ -253,7 +254,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
253254
}
254255
config.Debug("NewAPIRequest response status code:", response.StatusCode)
255256

256-
if response.StatusCode == http.StatusUnauthorized {
257+
if response.StatusCode == http.StatusUnauthorized && !usingApiKeySecretKey {
257258
r.Client().Jar, _ = cookiejar.New(nil)
258259
sessionKey, err := Login(r)
259260
if err != nil {

0 commit comments

Comments
 (0)