Skip to content

Conversation

@sampan-s-nayak
Copy link
Contributor

@sampan-s-nayak sampan-s-nayak commented Oct 27, 2025

Description

extend token auth support to dashboard head (all API's)

sampan and others added 30 commits October 16, 2025 08:35
Signed-off-by: sampan <sampan@anyscale.com>
- Created RayAuthTokenLoader singleton class with thread-safe token caching
- Loads tokens from RAY_AUTH_TOKEN env, RAY_AUTH_TOKEN_PATH, or ~/.ray/auth_token
- Support for token generation with UUID (cross-platform)
- Modified GrpcServer to store and pass auth token to ServerCallImpl
- Updated RPC_SERVICE_HANDLER macros to pass auth token
- GCS server now loads token using RayAuthTokenLoader
- Removed auth_token from RayConfig (now loaded via loader)
- Token precedence: env var -> path env var -> default file path

Signed-off-by: sampan <sampan@anyscale.com>
- Created Python auth_token_loader module with thread-safe token caching
- Loads tokens from same precedence as C++: RAY_AUTH_TOKEN, RAY_AUTH_TOKEN_PATH, ~/.ray/auth_token
- Added enable_token_auth parameter to ray.init() with auto-generation support
- Added --enable-token-auth flag to ray start CLI (fails if no token found)
- Only pass enable_token_auth flag via system_config, not the token
- Each side (C++/Python) loads tokens independently using their own loaders
- ray.init() auto-generates token if not found, ray start fails with helpful error

Signed-off-by: sampan <sampan@anyscale.com>
- Test token loading from RAY_AUTH_TOKEN environment variable
- Test token loading from RAY_AUTH_TOKEN_PATH file
- Test token loading from default ~/.ray/auth_token path
- Test precedence order (env var > path env var > default file)
- Test token generation with GetToken(true)
- Test token caching behavior
- Test thread safety with concurrent GetToken calls
- Test whitespace trimming from token files
- Test behavior when no token is found

Signed-off-by: sampan <sampan@anyscale.com>
- Test token loading from RAY_AUTH_TOKEN environment variable
- Test token loading from RAY_AUTH_TOKEN_PATH file
- Test token loading from default ~/.ray/auth_token path
- Test precedence order (env var > path env var > default file)
- Test token generation with generate_if_not_found=True
- Test token caching behavior across multiple calls
- Test has_auth_token() function
- Test thread safety with concurrent loads and generation
- Test whitespace handling and empty values
- Test file permissions on Unix systems (0600)
- Test error handling for permission errors
- Test integration with fixtures and cleanup

Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
@edoakes
Copy link
Collaborator

edoakes commented Oct 28, 2025

lots of test failures

Signed-off-by: sampan <sampan@anyscale.com>
@sampan-s-nayak
Copy link
Contributor Author

lots of test failures

ah I think I missed .py in bazel file.

cursor[bot]

This comment was marked as outdated.

sampan and others added 4 commits October 28, 2025 15:54
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Base automatically changed from grpc_auth_2 to master October 30, 2025 13:54
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
from ray._raylet import Config


@pytest.fixture
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sampan-s-nayak I pushed a commit to clean up the fixtures a bit here, FYI

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also moved it into the dashboard/tests/ dir

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I had another pr where I refactored all these fixtures and moved them to conf test

return GetAuthenticationMode()


def validate_authentication_token(provided_token: str) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like this could be implemented fully in the C++ layer?

@edoakes edoakes enabled auto-merge (squash) October 30, 2025 14:20
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
@github-actions github-actions bot disabled auto-merge October 30, 2025 15:42
@edoakes edoakes enabled auto-merge (squash) October 30, 2025 15:43
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
@github-actions github-actions bot disabled auto-merge October 30, 2025 16:30
@edoakes edoakes merged commit fef5fa6 into master Oct 30, 2025
6 checks passed
@edoakes edoakes deleted the token_auth_4 branch October 30, 2025 21:25
YoussefEssDS pushed a commit to YoussefEssDS/ray that referenced this pull request Nov 8, 2025
Extend token auth support to dashboard head (all API's)

---------

Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: Sampan S Nayak <sampansnayak2@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: sampan <sampan@anyscale.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
Extend token auth support to dashboard head (all API's)

---------

Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: Sampan S Nayak <sampansnayak2@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: sampan <sampan@anyscale.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Aydin-ab pushed a commit to Aydin-ab/ray-aydin that referenced this pull request Nov 19, 2025
Extend token auth support to dashboard head (all API's)

---------

Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: Sampan S Nayak <sampansnayak2@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: sampan <sampan@anyscale.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: Aydin Abiar <aydin@anyscale.com>
Future-Outlier pushed a commit to Future-Outlier/ray that referenced this pull request Dec 7, 2025
Extend token auth support to dashboard head (all API's)

---------

Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: Sampan S Nayak <sampansnayak2@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: sampan <sampan@anyscale.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants