dheeraj12347 commented on code in PR #232:
URL: 
https://github.com/apache/cloudstack-cloudmonkey/pull/232#discussion_r4789074353


##########
config/config.go:
##########
@@ -457,12 +458,15 @@ func (c *Config) UpdateConfig(key string, value string, 
update bool) {
        case "profile":
                c.Core.ProfileName = value
                c.ActiveProfile = nil
+               c.CredentialsSupplied = false

Review Comment:
   **Bug: `CredentialsSupplied` is not reset when switching profiles**
   
   The new `CredentialsSupplied` flag is reset when the profile is changed 
through `UpdateConfig()`, but the interactive `switch profile` command calls 
`LoadProfile()` directly. `LoadProfile()` does not reset this flag.
   
   This causes an authentication failure when CloudMonkey is started with CLI 
API credentials (`-k` and `-s`) and the user subsequently switches to a profile 
configured with username/password authentication.
   
   **Steps to reproduce:**
   1. Start CloudMonkey with CLI API credentials:
      `cmk -p testprofile -k CLI_API_KEY -s CLI_SECRET_KEY`
   2. Run `switch profile passwordprofile`.
   3. Run `list zones`.
   
   The newly loaded profile contains valid username/password credentials, but 
CloudMonkey still treats the session as using CLI-supplied API credentials. 
Consequently, it skips username/password login and the API request fails.
   
   I reproduced this locally using a mock API server. The same profile change 
through `set profile passwordprofile` correctly resets the flag and attempts a 
login request.
   
   **Suggestion:** Reset `CredentialsSupplied` when `LoadProfile()` 
successfully loads a profile, so both startup profile loading and interactive 
profile switching maintain consistent authentication state.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to