ramackri commented on code in PR #1394:
URL: https://github.com/apache/ranger/pull/1394#discussion_r4708720423
##########
security-admin/src/main/java/org/apache/ranger/biz/UserMgr.java:
##########
@@ -1357,6 +1383,61 @@ private void applyConfigSuperUserProfileOverrides(final
VXPortalUser userProfile
userProfile.setUserPermList(effectiveModules);
}
+ private void applyHeaderAuthnProfileOverrides(final VXPortalUser
userProfile, final UserSessionBase sess, final XXPortalUser user) {
+ if (sess == null || userProfile == null || user == null) {
+ return;
+ }
+
+ if (sess.getXXPortalUser() == null ||
!sess.getXXPortalUser().getId().equals(user.getId())) {
+ return;
+ }
+
+ Authentication authentication =
SecurityContextHolder.getContext().getAuthentication();
+
+ if (authentication instanceof RangerAuthenticationToken &&
((RangerAuthenticationToken) authentication).getAuthType() ==
XXAuthSession.AUTH_TYPE_TRUSTED_PROXY) {
+ Set<String> userRoles = new
HashSet<>();
+ Collection<? extends GrantedAuthority> grantedAuthorities =
authentication.getAuthorities();
+
+ if (grantedAuthorities != null) {
+ for (GrantedAuthority grantedAuth : grantedAuthorities) {
+ String roleName = grantedAuth.getAuthority();
+
+ userRoles.add(roleName);
+
+ logger.debug("Adding header role {} to session user {} in
user profile", roleName, sess.getLoginId());
+ }
+ }
+
+ List<VXUserPermission> effectiveModules = new ArrayList<>();
+ List<String> effectiveRoles = new
ArrayList<>(userRoles);
+
+ if (userRoles.contains(RangerConstants.ROLE_SYS_ADMIN) ||
userRoles.contains(RangerConstants.ROLE_ADMIN_AUDITOR)) {
Review Comment:
@dineshkumar-yadav
After the existing sys-admin / admin-auditor branch, an else if for
ROLE_KEY_ADMIN or ROLE_KEY_ADMIN_AUDITOR fills effectiveModules with the same
modules as DB key-admin provisioning in XUserMgr (resource policies, reports,
audit, users/groups, governed data sharing, key manager), using the existing
inline VXUserPermission pattern and findByModuleName.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]