@@ -346,43 +346,27 @@ class ServerCallImpl : public ServerCall {
346346 bool ValidateAuthenticationToken () {
347347 AuthenticationMode auth_mode = GetAuthenticationMode ();
348348
349+ if (auth_mode == AuthenticationMode::DISABLED) {
350+ return true ;
351+ }
352+
349353 const auto &metadata = context_.client_metadata ();
350354 auto it = metadata.find (kAuthTokenKey );
351355
352356 if (auth_mode == AuthenticationMode::TOKEN) {
353357 if (!auth_token_.has_value () || auth_token_->empty ()) {
354358 return true ; // No auth required on server side
355359 }
356- if (it == metadata.end ()) {
357- RAY_LOG (WARNING)
358- << " Missing authorization header in request for token auth mode!" ;
359- return false ;
360- }
361- const std::string_view header (it->second .data (), it->second .length ());
362- AuthenticationToken provided_token = AuthenticationToken::FromMetadata (header);
363- if (!auth_token_->Equals (provided_token)) {
364- RAY_LOG (WARNING) << " Invalid bearer token in request!" ;
365- return false ;
366- }
367- return true ;
368360 }
369361
370- if (auth_mode == AuthenticationMode::K8S) {
371- if (it == metadata.end ()) {
372- RAY_LOG (WARNING) << " Missing authorization header in request for k8s auth mode!" ;
373- return false ;
374- }
375- const std::string_view header (it->second .data (), it->second .length ());
376- AuthenticationToken provided_token = AuthenticationToken::FromMetadata (header);
377- if (provided_token.empty ()) {
378- RAY_LOG (WARNING) << " Empty bearer token in request for k8s auth mode!" ;
379- return false ;
380- }
381- return ray::rpc::AuthenticationTokenLoader::instance ().ValidateToken (
382- provided_token);
362+ if (it == metadata.end ()) {
363+ RAY_LOG (WARNING) << " Missing authorization header in request for token auth mode!" ;
364+ return false ;
383365 }
384366
385- return true ;
367+ const std::string_view header (it->second .data (), it->second .length ());
368+ AuthenticationToken provided_token = AuthenticationToken::FromMetadata (header);
369+ return ray::rpc::AuthenticationTokenLoader::instance ().ValidateToken (provided_token);
386370 }
387371
388372 // / Log the duration this query used
0 commit comments