Skip to content

fix(lk): --dev under --user-auth is an error - #1089

Open
Topherhindman wants to merge 2 commits into
mainfrom
topherhindman/dev-flag-under-user-auth
Open

Topherhindman wants to merge 2 commits into
mainfrom
topherhindman/dev-flag-under-user-auth

Conversation

@Topherhindman

Copy link
Copy Markdown
Contributor

Fixes DEVX-902

Under --user-auth, lk ignored --dev. No user-auth path reads it. lk --user-auth --dev room list asked the Public API for a token for the signed-in user's project and listed that project's rooms, not the local dev server's. lk --user-auth agent start --dev ran the agent with the cloud key from its .env.local. Nothing said --dev was dropped.

--dev asks for the dev server's API key, which is API-key auth. So the combination is now an error for every command, in the same way #1084 did for --dev with an API key or secret:

$ lk --user-auth --dev room list
--dev can't be combined with --user-auth; remove --user-auth or drop --dev

Before this change, the same command printed Using user [dev@example.com] and went to the user's cloud project.

The check runs once, in the root Before, so it doesn't matter where on the command line either flag goes. --dev alone and --user-auth alone are unchanged.

Tests:

  • TestDevUnderUserAuthGate: both spellings of --user-auth with --dev fail with the message, and each flag alone doesn't.
  • A script test (dev-with-user-auth.txtar): room list and project list fail with no request to the session's project or the Public API, and --dev alone still uses the dev credentials with a user signed in. It fails on main.
  • The credential property test now requires --dev under --user-auth to fail without naming a project. It passes with 1000 checks.
  • go build ./..., go vet ./... and go test ./... pass.

No user-auth path reads --dev. Commands that load a session project
asked the Public API for a token for the user's project, and agent runs
took their key from the agent's env files, so `lk --user-auth --dev
room list` acted on a cloud project instead of the local dev server,
without a word about --dev.

--dev asks for the dev server's API key, which is API-key auth, so the
combination is now an error, checked once in the root Before so every
command gets it: "--dev can't be combined with --user-auth; remove
--user-auth or drop --dev". It follows --dev with an API key or secret,
which is also an error. --dev alone and --user-auth alone are unchanged.
--dev under --user-auth is now an error for every command, so the
property requires lk to fail without naming a project, as it does for
--user-auth with --legacy-auth.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant