Skip to content

Commit

Permalink
HDDS-6175. Use s3Auth during proxy during decrypt in RpcClient. (apac…
Browse files Browse the repository at this point in the history
…he#2981)

* HDDS-6175. Use s3Auth during proxy during decrypt in RpcClient.
  • Loading branch information
bharatviswa504 authored and Jackson Yao committed Feb 9, 2022
1 parent 63fb648 commit 4a17414
Showing 1 changed file with 10 additions and 6 deletions.
Expand Up @@ -863,13 +863,17 @@ private KeyProvider.KeyVersion getDEK(FileEncryptionInfo feInfo)
OzoneKMSUtil.checkCryptoProtocolVersion(feInfo);
KeyProvider.KeyVersion decrypted = null;
try {
// Do proxy thing only when current UGI not matching with login UGI
// In this way, proxying is done only for s3g where
// s3g can act as proxy to end user.

// After HDDS-5881 the user will not be different,
// as S3G uses single RpcClient. So we should be checking thread-local
// S3Auth and use it during proxy.
UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
if (!ugi.getShortUserName().equals(loginUser.getShortUserName())) {
UserGroupInformation proxyUser = UserGroupInformation.createProxyUser(
ugi.getShortUserName(), loginUser);
UserGroupInformation proxyUser;
if (getThreadLocalS3Auth() != null) {
UserGroupInformation s3gUGI = UserGroupInformation.createRemoteUser(
getThreadLocalS3Auth().getAccessID());
proxyUser = UserGroupInformation.createProxyUser(
s3gUGI.getShortUserName(), loginUser);
decrypted = proxyUser.doAs(
(PrivilegedExceptionAction<KeyProvider.KeyVersion>) () -> {
return OzoneKMSUtil.decryptEncryptedDataEncryptionKey(feInfo,
Expand Down

0 comments on commit 4a17414

Please sign in to comment.