Skip to content

Commit ca0b549

Browse files
committed
fix(cli): prevent false user-attended mode warning with federated auth
When using OIDC federated authentication (e.g., GitHub Actions), the CLI incorrectly showed a "User-attended mode detected" warning. This happened because loadAuthToken() returned isUserToken=true when no API token was configured, and federated auth discovery never updated this flag. Two fixes applied: - Set isUserToken=false after obtaining a federated token, so the flag correctly reflects the authentication method - Guard the confirmation prompt with authToken != "" to skip it entirely when no token is available, preventing the prompt from showing in unauthenticated scenarios Signed-off-by: Miguel Martinez <miguel@chainloop.dev> Entire-Checkpoint: 1ff68ba64bcc
1 parent c968cba commit ca0b549

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/cli/cmd/root.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
127127
if r.IsAuthenticated() && r.FederatedToken() != "" {
128128
logger.Debug().Str("runner", r.ID().String()).Msg("using federated auth token")
129129
authToken = r.FederatedToken()
130+
// reset isUserToken to false because we are using a federated token and we don't want to ask for confirmation
131+
isUserToken = false
130132
}
131133
}
132134

@@ -168,7 +170,7 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
168170
}
169171

170172
// Warn users when the session is interactive, and the operation is supposed to use an API token instead
171-
if shouldAskForConfirmation(cmd) && isUserToken && !flagYes {
173+
if shouldAskForConfirmation(cmd) && authToken != "" && isUserToken && !flagYes {
172174
logger.Warn().Msg("User-attended mode detected. This is intended for local testing only. For CI/CD or automated workflows, please use an API token.")
173175
if !confirmationPrompt(fmt.Sprintf("This command will run against the organization %q", orgName)) {
174176
return errors.New("command canceled by user")

0 commit comments

Comments
 (0)