Repository navigation
feat(auth)!: LiveKit CLI 3.0: sign in by default, API keys behind --legacy-auth - #1158
Draft
rektdeckard wants to merge 3 commits into
Draft
rektdeckard wants to merge 3 commits into
rektdeckard wants to merge 3 commits into
Conversation
Commands now run as the signed-in LiveKit Cloud user unless something asks for an API key. One resolver decides, first match wins: --legacy-auth, --user-auth (now hidden: it is the default), LIVEKIT_LEGACY_AUTH, --dev, --api-key or --api-secret on the command line, a self-hosted target, a saved auth_mode: legacy, a signed-in user, and then an API key that is at hand when nobody is signed in. LIVEKIT_API_KEY and LIVEKIT_API_SECRET in the environment alone don't take a signed-in user off their session. A machine set up for 2.x keeps working. With a LiveKit Cloud key and nobody signed in, a terminal is asked once whether to sign in or keep using API keys, and a run that can't ask goes on with the key and prints a warning. A key for a self-hosted server prints nothing. Also in this change: - lk cloud auth signs in, with no terminal needed: the device is named after the host and the link is printed. --project sets the default project. With --legacy-auth it claims an API key as before. --revoke with nobody signed in says how to revoke a key instead. - A command that needs a signed-in user offers to sign in when it can ask. - Commands and flags for signed-in users are listed in help. Unlisted ones stay hidden. - lk token create refuses a --valid-for over 24h for a signed-in user, which the API would shorten without saying. - lk agent dev runs an agent whose SDK has token mode (livekit-agents 1.19.0 or later for Python, @livekit/agents 1.11.0 or later for Node.js) with a worker token when no key can be found or created, as the last step of the key chain. A hidden --token-mode asks for it first. - A key prompt while setting up a new app or agent can be skipped. - lk update and lk can-update warn before a major update, with a link to its migration guide. - A follow-up command that lk prints repeats an auth mode flag that chose the mode. - The config permissions warning prints once per run. - Tests no longer read the CLI config or session of the machine they run on, which the default mode now depends on. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…on 3.0.0 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
banner.json on main is what installed CLIs read, so this reaches 2.x users before they update, which the notice in lk update can't until it ships in the binary they run. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
rektdeckard
force-pushed
the
tobiasfried/cli-3-user-auth-default
branch
from
December 3, 2026 00:51
d1cc4a2 to
9e3c377
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LiveKit CLI 3.0. Commands run as the signed-in LiveKit Cloud user by default. API keys stay available behind
--legacy-authandLIVEKIT_LEGACY_AUTH, which #1156 added in 2.20.2. Follows #1156 (merged).Two commits: the behavior change, then the mechanical module rename to
/v3with the version bump. Review them separately.How a command picks its auth mode
One resolver (
cmd/lk/auth_mode.go) decides. The first match wins:--legacy-auth: API key--user-auth: signed-in user. It is now hidden, since it is the default, and still overrides the rules belowLIVEKIT_LEGACY_AUTH: API key--dev: API key--api-keyor--api-secreton the command line: API key--urlorLIVEKIT_URLwith a key and secret, or--projectnaming a saved self-hosted projectauth_mode: legacyin the CLI config: API keyLIVEKIT_API_KEYandLIVEKIT_API_SECRETin the environment alone don't take a signed-in user off their session.What a 2.x setup sees
LIVEKIT_LEGACY_AUTH=1or--legacy-authremoves it.auth_mode: legacy), or decide later.--user-auth: nothing to do. The flag still works.Behavior changes
lk cloud authsigns in, and needs no terminal: the device is named after the host and the link is printed. With--legacy-authit claims an API key as before.lk cloud auth --projectsets the default project after sign-in. With several projects and nobody to ask, no default is set and lk says how to set one.lk cloud auth --revokesigns out. With nobody signed in, it says to pass--legacy-authto revoke a key.lk token create --valid-forover 24h fails for a signed-in user. The API would shorten it without saying.lk agent devruns the agent with a worker token (LIVEKIT_TOKEN, support for token mode agents#8557, token mode: supports running without an api key/secret agents-js#2999) when no key can be found or created. It is the last step of the key chain, and only for an SDK with token mode: livekit-agents 1.19.0 or later for Python,@livekit/agents1.11.0 or later for Node.js. A hidden--token-modeasks for it first.lk agent initandlk app createcan be skipped.lk updateandlk can-updatewarn before a major update and link its migration guide.--user-author--legacy-authwhen that flag chose the mode.github.com/livekit/livekit-cli/v3. Version is 3.0.0.Open points
release.yamlblocks a 3.0.0 release. It requires the CLI's major.minor to match server-sdk-go's, which stays on v2. Left unchanged here on purpose.banner.jsonon main reaches installed 2.x CLIs, and this PR adds a notice there for< 3.0.0that links the migration guide. Merge it when 3.0.0 is released and the guide is published./reference/developer-tools/livekit-cli/migrate-to-v3/) is on a livekit/web branch that isn't pushed yet.Testing
go test ./...passes.TestDecideAuthModecovers every resolver rule, with flags on both sides of the subcommand.TestCredentialResolution(property test) has a second telling of the mode rules and passes 5000 random cases.cloud-auth-signs-in,auth-fallback-to-api-key,token-create-valid-for-cap,agent-dev-token-mode. Existing scripts are updated for the new default and messages.🤖 Generated with Claude Code