Repository navigation
[Fix][Core/Auth] Enable token auth in C++ and Java drivers that start their own local cluster - #66778
Merged
rueian merged 2 commits intoOct 6, 2026
Merged
Conversation
… their own local cluster Signed-off-by: Chi-Sheng Liu <[email protected]>
MortalHappiness
force-pushed
the
fix/ray-cpp-token-auth
branch
from
October 6, 2026 11:24
cfd8d50 to
24e78e3
Compare
MortalHappiness
marked this pull request as ready for review
October 6, 2026 22:18
MortalHappiness
requested review from
a team,
SongGuyang,
kfstorm and
raulchen
as code owners
October 6, 2026 22:18
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces automatic token authentication enablement for C++ and Java drivers when a token is available and RAY_AUTH_MODE is unset. It adds the MaybeEnableTokenAuthIfTokenAvailable helper in C++ and exposes it to Java via JNI. However, a critical issue was identified in the Java runtime implementation: restricting the token auth auto-enablement to only when startRayHead is true will cause Java drivers to fail with InvalidAuthToken when connecting to an existing token-enabled cluster. It is recommended to call nativeMaybeEnableTokenAuthIfTokenAvailable() unconditionally for all Java drivers.
rueian
approved these changes
Oct 6, 2026
sai-miduthuri
added a commit
that referenced
this pull request
Oct 13, 2026
…va drivers that start their own local cluster (#66778) (#66801) Cherry-pick of #66778 (master commit 8bf3d3e) onto `releases/2.60.0`. `releases/2.60.0` already has #64755 (token auth enabled by default for local clusters) and #66467, so C++ and Java drivers that start their own head fail with `InvalidAuthToken` on this branch too: `ray start --head` enables token auth when `RAY_AUTH_MODE` is unset and `~/.ray/auth_token` exists, but the driver's auth mode stays `disabled`. The release sanity check hits this. The fix adds `MaybeEnableTokenAuthIfTokenAvailable()` next to the token loader and calls it from both drivers only when they started the head. Applied cleanly with `git cherry-pick -x`; the diff is identical to the master commit. All 9 touched files, plus the APIs the new code calls (`TryLoadToken(ignore_auth_mode)`, `SetEnv`), are byte-identical to master at 8bf3d3e after the pick. Not a duplicate: no existing PR against `releases/2.60.0` references #66778. Testing: relying on release-branch CI (`//cpp:metric_example`, which now runs without `RAY_AUTH_MODE` to cover this path, plus the C++ and Java driver tests); no local tests run. AI assistance was used to prepare this cherry-pick. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Chi-Sheng Liu <[email protected]> Signed-off-by: sai.miduthuri <[email protected]> Co-authored-by: Chi-Sheng Liu <[email protected]>
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.
Description
Since #64755,
ray start --headenables token auth whenRAY_AUTH_MODEis unset and~/.ray/auth_tokenexists, for example after any earlier Pythonray.init(). C++ and Java drivers that start their own head don't make the same decision: their auth mode staysdisabled, so they connect without a token and fail withInvalidAuthToken. The release sanity check hits this. #66467 fixed the same mismatch for Pythonray.init().This PR adds
MaybeEnableTokenAuthIfTokenAvailable()next to the token loader. WhenRAY_AUTH_MODEis unset and a token exists, it setsRAY_AUTH_MODE=tokenin the process environment so that the laterRayConfigre-initialization keeps it. Both drivers call it, only when they started the head:Drivers given an explicit address are unchanged.
//cpp:metric_examplenow runs withoutRAY_AUTH_MODEto cover this path.Related issues
N/A
Additional information
N/A