Skip to content
Open
Changes from 1 commit
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
23 changes: 22 additions & 1 deletion packages/util/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,28 @@
}
}

if infisicalToken == "" { // If it's empty, we return nothing at all.
if infisicalToken == "" {
// Check if Universal Auth client credentials are available for automatic authentication.
// This allows commands like `infisical run` to work when INFISICAL_UNIVERSAL_AUTH_CLIENT_ID
// and INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET are set, without requiring a prior `infisical login`.
clientId := os.Getenv(INFISICAL_UNIVERSAL_AUTH_CLIENT_ID_NAME)
clientSecret := os.Getenv(INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET_NAME)

if clientId != "" && clientSecret != "" {
log.Debug().Msg("No explicit token found, attempting automatic authentication via Universal Auth client credentials")
loginResponse, err := UniversalAuthLogin(clientId, clientSecret)
if err != nil {
Comment thread
varonix0 marked this conversation as resolved.
Outdated
return nil, fmt.Errorf("failed to authenticate with Universal Auth using %s and %s environment variables: %w",
INFISICAL_UNIVERSAL_AUTH_CLIENT_ID_NAME, INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET_NAME, err)
}

Check failure on line 319 in packages/util/helper.go

View check run for this annotation

Claude / Claude Code Review

Auto-auth inherits 10000-retry policy, can hang for hours on transient network failure

This PR makes `GetInfisicalToken` call `UniversalAuthLogin` automatically on every CLI invocation, but `UniversalAuthLogin` is configured with `SetRetryCount(10000)` and `SetRetryMaxWaitTime(20s)` (helper.go:347-363) β€” so a sustained transport-level failure (DNS, connection refused, TLS) will block one-shot commands like `infisical run` / `infisical secrets get` for many hours instead of failing fast. This is exactly the opposite of what CI runners and automation contexts (the audience the PR de
Comment thread
varonix0 marked this conversation as resolved.
Outdated

return &models.TokenDetails{
Type: UNIVERSAL_AUTH_TOKEN_IDENTIFIER,
Token: loginResponse.AccessToken,
Source: fmt.Sprintf("%s and %s environment variables", INFISICAL_UNIVERSAL_AUTH_CLIENT_ID_NAME, INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET_NAME),
}, nil
}

Check failure on line 326 in packages/util/helper.go

View check run for this annotation

Claude / Claude Code Review

GetInfisicalToken now performs network call, causing duplicate auth in PreRun

PersistentPreRun in packages/cmd/root.go:115 calls GetInfisicalToken purely to detect a token's source and print a 'session is being overwritten' warning. With this PR, when an interactively-logged-in user also has INFISICAL_UNIVERSAL_AUTH_CLIENT_ID/SECRET set, GetInfisicalToken now performs a network UniversalAuthLogin in PreRun, then the subcommand calls GetInfisicalToken again and mints a second token β€” doubling auth API calls per command and adding a long-retry network dependency (10000 retr
Comment thread
varonix0 marked this conversation as resolved.
Outdated

return nil, nil
}

Expand Down
Loading