Skip to content
Closed
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3220,16 +3220,16 @@ void ensureAdminAccess(RangerPolicy policy, String grantor) {
final boolean isAdmin;
final boolean isKeyAdmin;

if (StringUtils.isEmpty(grantor)) {
userName = bizUtil.getCurrentUserLoginId();
isAdmin = bizUtil.isAdmin();
isKeyAdmin = bizUtil.isKeyAdmin();
} else {
if (StringUtils.isEmpty(bizUtil.getCurrentUserLoginId()) && StringUtils.isNotEmpty(grantor)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in using service account identity (impala/hive/hbase) to authorize grant/revoke calls, which is not correct.

grant/revoke calls by services like Impala/HiveServer2/HBase authenticate with Ranger admin using their service account. The identity of the user entering grant/revoke statement is sent in grantor field of the payload. Ranger admin ensures that the grantor user has necessary privileages to perform the grant/revoke call. If the grantor user doesn't have privileges, the grant/revoke must fail. This is the correct behavior.

Collection<String> userRoles = userMgrGrantor.getRolesByLoginId(grantor);

userName = grantor;
isAdmin = userRoles.contains(RangerConstants.ROLE_SYS_ADMIN);
isKeyAdmin = userRoles.contains(RangerConstants.ROLE_KEY_ADMIN);
} else {
userName = bizUtil.getCurrentUserLoginId();
isAdmin = bizUtil.isAdmin();
isKeyAdmin = bizUtil.isKeyAdmin();
}
boolean isSvcAdmin = isAdmin || svcStore.isServiceAdminUser(policy.getService(), userName);

Expand Down