Skip to content

Commit

Permalink
HDDS-6175. Use s3Auth during proxy during decrypt in RpcClient. (#2981)
Browse files Browse the repository at this point in the history
* HDDS-6175. Use s3Auth during proxy during decrypt in RpcClient.
  • Loading branch information
bharatviswa504 committed Jan 13, 2022
1 parent 195737d commit 5447f58
Showing 1 changed file with 10 additions and 6 deletions.
Expand Up @@ -874,13 +874,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 5447f58

Please sign in to comment.