Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ce73705
Add authentication token logic and related tests
Oct 23, 2025
341b108
Add gRPC service and server logic with auth integration tests
Oct 23, 2025
c821c21
revert unneeded changs from src/ray/rpc/tests/BUILD.bazel
Oct 23, 2025
a14dc69
readd dependencies
Oct 23, 2025
7834733
Merge branch 'master' into token_auth_1
sampan-s-nayak Oct 24, 2025
4801ed7
address comments + fix build
Oct 24, 2025
65c3ded
Merge branch 'token_auth_1' into token_auth_2
sampan-s-nayak Oct 24, 2025
d24f23c
address comments
Oct 24, 2025
d801db6
Merge branch 'master' into token_auth_2
edoakes Oct 24, 2025
e9cc57f
address comments
Oct 26, 2025
f8c08e0
fix lint
Oct 26, 2025
b128e4e
Merge remote-tracking branch 'upstream/token_auth_2' into token_auth_2
Oct 26, 2025
c8cff1d
Merge branch 'master' into token_auth_2
sampan-s-nayak Oct 26, 2025
a7a8efa
fix ci
Oct 26, 2025
5a91771
Merge remote-tracking branch 'upstream/token_auth_2' into token_auth_2
Oct 26, 2025
5910ecf
fix build.bazel and imports
Oct 27, 2025
d36e22f
fix lint
Oct 27, 2025
4063d74
fix lint issues
Oct 27, 2025
9ac5eff
[Core] Support token auth in ray Pub-Sub
Oct 27, 2025
e3b8c3f
address comments
Oct 27, 2025
cd0f933
fix
edoakes Oct 27, 2025
199d18e
fix
edoakes Oct 27, 2025
537e90a
fix
edoakes Oct 27, 2025
17601c8
Merge branch 'master' into token_auth_2.5
sampan-s-nayak Oct 28, 2025
3bc34f2
[Core] Introduce new macros for user facing exceptions
Oct 28, 2025
e5b90ba
fix lint issues
Oct 28, 2025
acd95ac
dont print stack trace for user errors
Oct 28, 2025
c5be15f
address comments
Oct 28, 2025
f7f4ba2
Merge branch 'user_error_macro' into token_auth_2.5
sampan-s-nayak Oct 28, 2025
2698b8d
use RAY_USER_CHECK instead of RAY_CHECK + fix test
Oct 28, 2025
8572c01
fix lint
Oct 28, 2025
d47ae2b
improve test
Oct 28, 2025
d054131
fix lint
Oct 28, 2025
2ee5555
fix lint
Oct 28, 2025
06a71b4
Merge branch 'master' into user_error_macro
sampan-s-nayak Oct 28, 2025
8b4fc91
Merge branch 'user_error_macro' into token_auth_2.5
sampan-s-nayak Oct 28, 2025
15aa5e2
attempt to fix test
Oct 28, 2025
1c600e6
fix test
Oct 29, 2025
f23ea2e
revert logging changes
Oct 31, 2025
4646909
address comments
Oct 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/ray/pubsub/python_gcs_subscriber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <vector>

#include "ray/gcs_rpc_client/rpc_client.h"
#include "ray/rpc/authentication/authentication_token_loader.h"

namespace ray {
namespace pubsub {
Expand Down Expand Up @@ -51,6 +52,7 @@ Status PythonGcsSubscriber::Subscribe() {
}

grpc::ClientContext context;
SetAuthenticationToken(context);

rpc::GcsSubscriberCommandBatchRequest request;
request.set_subscriber_id(subscriber_id_);
Expand Down Expand Up @@ -78,6 +80,7 @@ Status PythonGcsSubscriber::DoPoll(int64_t timeout_ms, rpc::PubMessage *message)
return Status::OK();
}
current_polling_context_ = std::make_shared<grpc::ClientContext>();
SetAuthenticationToken(*current_polling_context_);
if (timeout_ms != -1) {
current_polling_context_->set_deadline(std::chrono::system_clock::now() +
std::chrono::milliseconds(timeout_ms));
Expand Down Expand Up @@ -173,6 +176,7 @@ Status PythonGcsSubscriber::Close() {
}

grpc::ClientContext context;
SetAuthenticationToken(context);

rpc::GcsSubscriberCommandBatchRequest request;
request.set_subscriber_id(subscriber_id_);
Expand All @@ -195,5 +199,12 @@ int64_t PythonGcsSubscriber::last_batch_size() {
return last_batch_size_;
}

void PythonGcsSubscriber::SetAuthenticationToken(grpc::ClientContext &context) {
auto auth_token = ray::rpc::AuthenticationTokenLoader::instance().GetToken();
if (auth_token.has_value() && !auth_token->empty()) {
auth_token->SetMetadata(context);
}
}

} // namespace pubsub
} // namespace ray
4 changes: 4 additions & 0 deletions src/ray/pubsub/python_gcs_subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class RAY_EXPORT PythonGcsSubscriber {
std::deque<rpc::PubMessage> queue_ ABSL_GUARDED_BY(mu_);
bool closed_ ABSL_GUARDED_BY(mu_) = false;
std::shared_ptr<grpc::ClientContext> current_polling_context_ ABSL_GUARDED_BY(mu_);

// Set authentication token on a gRPC client context if token-based authentication is
// enabled
void SetAuthenticationToken(grpc::ClientContext &context);
};

/// Get the .lines() attribute of a LogBatch as a std::vector
Expand Down
17 changes: 17 additions & 0 deletions src/ray/pubsub/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,20 @@ ray_cc_test(
"@com_google_googletest//:gtest_main",
],
)

ray_cc_test(
name = "python_gcs_subscriber_auth_test",
size = "small",
srcs = ["python_gcs_subscriber_auth_test.cc"],
tags = ["team:core"],
deps = [
"//src/ray/common:ray_config",
"//src/ray/common:status",
"//src/ray/protobuf:gcs_service_cc_grpc",
"//src/ray/pubsub:python_gcs_subscriber",
"//src/ray/rpc:grpc_server",
"//src/ray/rpc/authentication:authentication_token",
"//src/ray/rpc/authentication:authentication_token_loader",
"@com_google_googletest//:gtest_main",
],
)
Loading