Repository navigation
[ISSUE #94] Support Bearer token authentication via --token - #95
Merged
KomachiSion merged 2 commits intoJul 15, 2026
Merged
Conversation
saynoword
marked this pull request as ready for review
July 15, 2026 03:14
Contributor
|
🚨 Critical: Token flag not checked in config loading logic The Current code: hasCommandLineConfig := host != "" || port > 0 || serverAddr != "" ||
username != "" || password != "" || accessKey != "" ||
secretKey != "" || securityToken != "" ||
isCommandLineStsAuthType(authType) || scheme != ""Problem: nacos-cli --host 127.0.0.1 --port 8848 --token my-bearer-token skill-listThe CLI treats this as "no command-line config" because
Fix: hasCommandLineConfig := host != "" || port > 0 || serverAddr != "" ||
username != "" || password != "" || accessKey != "" ||
secretKey != "" || securityToken != "" || token != "" ||
isCommandLineStsAuthType(authType) || scheme != ""This aligns token with other credential flags and preserves the documented precedence: command line > profile > env vars > default. |
KomachiSion
approved these changes
Jul 15, 2026
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.
Please do not create a Pull Request without creating an issue first.
Fixes #94
What is the purpose of the change
Allow users who already have a Nacos access token to authenticate CLI requests directly with the standard
Authorization: Bearer <token>header, without requiring another username/password login. Token authentication can be supplied for one command or stored securely in a reusable profile.Brief changelog
--tokenoption to the root command.auth-type=tokenwith an encryptedtokenfield in profiles.Verifying this change
GOCACHE=/private/tmp/nacos-cli-go-build go vet ./...GOCACHE=/private/tmp/nacos-cli-go-build go test ./...go run . --host 127.0.0.1 --port 8848 --token <token> skill-list --size 1 --output json.go run . profile set dev host=127.0.0.1 port=8848 auth-type=token token=<token>, confirmprofile get dev tokenprints******, and rungo run . --profile dev skill-list --size 1 --output json.Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check spotbugs:check -DskipTeststo make sure basic checks pass. Runmvn clean install -DskipITsto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.