Skip to content

fix(auth): auto-provision staging environment after login#89

Merged
nicknisi merged 2 commits intomainfrom
feat/auto-env-after-login
Mar 10, 2026
Merged

fix(auth): auto-provision staging environment after login#89
nicknisi merged 2 commits intomainfrom
feat/auto-env-after-login

Conversation

@nicknisi
Copy link
Member

@nicknisi nicknisi commented Mar 9, 2026

Summary

After workos auth login succeeds, the CLI now automatically fetches staging credentials and saves them as a default "staging" environment. This bridges the OAuth auth system with the API key system so management commands (e.g., workos env list) work immediately without requiring a manual workos env add step.

What was tested

Automated

  • 1030/1030 tests pass (8 new tests added)
  • pnpm typecheck clean
  • pnpm build clean
  • New tests cover: success path, existing env preservation, env update, and failure paths (403, 404, network error, timeout)

Manual

  • Code review of login.ts diff verified provisionStagingEnvironment is called after saveCredentials in runLogin, wrapped in try/catch, returns boolean
  • Confirmed all error paths return false and never throw
  • Confirmed active env logic correctly uses isFirst || !config.activeEnvironment guard
  • Verified type compatibility with staging-api.ts and config-store.ts

Verification

CLI-only change with no frontend UI. Verification based on comprehensive test execution and code review.

Screenshots

after.png

Issue

User-reported: after workos auth login, workos env list showed "No environments configured." Expected login to bootstrap a default environment.

Follow-ups

  • Consider making the auto-provisioned environment name configurable (currently hardcoded to "staging")
  • Could add a --no-auto-env flag to skip auto-provisioning if needed

nicknisi added 2 commits March 9, 2026 15:35
After workos auth login succeeds, automatically fetch staging credentials and save them as a staging environment in the config store. This eliminates the need for users to manually run workos env add before management commands work.

If the staging API fails (403/404/network), the login still succeeds and a hint is printed to configure an environment manually.
@nicknisi nicknisi changed the title feat(auth): auto-provision staging environment after login fix(auth): auto-provision staging environment after login Mar 10, 2026
@nicknisi nicknisi merged commit 19b34e2 into main Mar 10, 2026
3 checks passed
@nicknisi nicknisi deleted the feat/auto-env-after-login branch March 10, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant