Skip to content

Prioritize LOCALSTACK_AUTH_TOKEN over stored credentials - #415

Open
gtsiolis wants to merge 1 commit into
mainfrom
devx-1023-environment-auth-token-should-override-stored-8cf6
Open

Prioritize LOCALSTACK_AUTH_TOKEN over stored credentials#415
gtsiolis wants to merge 1 commit into
mainfrom
devx-1023-environment-auth-token-should-override-stored-8cf6

Conversation

@gtsiolis

@gtsiolis gtsiolis commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

Stored keyring credentials previously overrode LOCALSTACK_AUTH_TOKEN. Once a user had logged in, a token supplied for a CI job, a second account, or a single invocation was silently ignored until the stored credential was removed.

This change makes caller-provided authentication authoritative. Token resolution is now:

  1. LOCALSTACK_AUTH_TOKEN
  2. Stored keyring credentials
  3. Browser login, when the command supports it

The non-interactive resolution used by telemetry, snapshot commands, extensions, and emulator startup shares the same precedence helper as auth.GetToken, preventing the two paths from drifting. Tokens are trimmed before resolution, so an empty or whitespace-only environment value does not mask a valid stored credential.

This also composes with DEVX-1022's authentication boundary. An environment token overrides a stored token and is sent as the caller credential for both local and external emulator-backed Cloud Pod operations. Reuse of a locally managed emulator's startup identity is only considered when neither an environment nor stored caller token is available; external targets still require caller authentication.

Logout behavior is unchanged: it removes stored credentials, while an environment-provided token remains controlled by the caller's environment.

Verification

  • go test ./internal/auth ./cmd
  • make test-integration RUN='Test(EnvAuthTokenOverridesStoredToken|StoredTokenUsedWithoutEnvAuthToken)'
  • make test-integration RUN='TestLogoutCommand(RemovesToken|SucceedsWhenNoToken|WithEnvVarToken)$'
  • go vet ./... in the root and integration-test modules
  • Pre-commit secret scan

Review: advisable — this changes credential precedence for every authenticated command and defines how explicit caller credentials interact with the local-emulator identity fallback.

Co-Authored-By: Claude noreply@anthropic.com

Closes DEVX-1023

@gtsiolis gtsiolis added semver: patch docs: skip Pull request does not require documentation changes labels Jul 28, 2026
@gtsiolis gtsiolis self-assigned this Jul 28, 2026
Co-Authored-By: Claude <noreply@anthropic.com>
@gtsiolis
gtsiolis force-pushed the devx-1023-environment-auth-token-should-override-stored-8cf6 branch from 521544e to 33318d2 Compare August 4, 2026 22:44
@gtsiolis gtsiolis changed the title Make LOCALSTACK_AUTH_TOKEN take precedence over stored credentials Prioritize LOCALSTACK_AUTH_TOKEN over stored credentials Aug 4, 2026
@gtsiolis
gtsiolis marked this pull request as ready for review August 4, 2026 22:44
@gtsiolis
gtsiolis requested a review from a team as a code owner August 4, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs: skip Pull request does not require documentation changes semver: patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant