Skip to content

Commit 3c5cdaf

Browse files
author
hiddenpath
committed
YT-23616: Add IsUnauthorized method to TErrorResponse
commit_hash:eb23d10ce4143a7cc122794f85c66072b317fc44
1 parent 5bf080f commit 3c5cdaf

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

yt/cpp/mapreduce/interface/errors.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,22 @@ bool TErrorResponse::IsAccessDenied() const
355355
return Error_.ContainsErrorCode(NClusterErrorCodes::NSecurityClient::AuthorizationError);
356356
}
357357

358+
bool TErrorResponse::IsUnauthorized() const
359+
{
360+
const auto allCodes = Error_.GetAllErrorCodes();
361+
for (auto code : {
362+
NClusterErrorCodes::NRpc::AuthenticationError,
363+
NClusterErrorCodes::NRpc::InvalidCsrfToken,
364+
NClusterErrorCodes::NRpc::InvalidCredentials,
365+
NClusterErrorCodes::NSecurityClient::AuthenticationError,
366+
}) {
367+
if (allCodes.contains(code)) {
368+
return true;
369+
}
370+
}
371+
return false;
372+
}
373+
358374
bool TErrorResponse::IsConcurrentTransactionLockConflict() const
359375
{
360376
return Error_.ContainsErrorCode(NClusterErrorCodes::NCypressClient::ConcurrentTransactionLockConflict);

yt/cpp/mapreduce/interface/errors.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ class TErrorResponse
182182
/// Check if error was caused by lack of permissions to execute request.
183183
bool IsAccessDenied() const;
184184

185+
/// Check if error was caused by authorization issues.
186+
bool IsUnauthorized() const;
187+
185188
/// Check if error was caused by failure to lock object because of another transaction is holding lock.
186189
bool IsConcurrentTransactionLockConflict() const;
187190

0 commit comments

Comments
 (0)