ramackri commented on code in PR #1394:
URL: https://github.com/apache/ranger/pull/1394#discussion_r4708621362


##########
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:
   yes It seems we are not setting effectiveModules when a user logs in via 
header auth with authz-role-key-admin or 
authz-role-key-admin-auditor.SessionMgr.setUserRoles already sets keyAdmin / 
auditKeyAdmin from header roles, but the profile path does not mirror that for 
permissions
   cc >> @mneethiraj 



-- 
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]

Reply via email to