dineshkumar-yadav commented on code in PR #1394:
URL: https://github.com/apache/ranger/pull/1394#discussion_r4710034069
##########
security-admin/src/main/java/org/apache/ranger/biz/UserMgr.java:
##########
@@ -1357,6 +1383,72 @@ 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);
+ List<XXModuleDef> moduleDefs =
daoManager.getXXModuleDef().getAll();
+
+ if (CollectionUtils.isNotEmpty(moduleDefs)) {
+ XXUser xUser =
daoManager.getXXUser().findByPortalUserId(user.getId());
+ Long xUserId = xUser != null ? xUser.getId() : null;
+
+ if (userRoles.contains(RangerConstants.ROLE_SYS_ADMIN) ||
userRoles.contains(RangerConstants.ROLE_ADMIN_AUDITOR)) {
+ for (XXModuleDef moduleDef : moduleDefs) {
+ if
(!RangerConstants.MODULE_KEY_MANAGER.equals(moduleDef.getModule())) {
+
effectiveModules.add(buildAllowedModulePerm(moduleDef, xUserId));
+ }
+ }
+ } else if (userRoles.contains(RangerConstants.ROLE_KEY_ADMIN)
|| userRoles.contains(RangerConstants.ROLE_KEY_ADMIN_AUDITOR)) {
+ for (String moduleName :
Arrays.asList(RangerConstants.MODULE_RESOURCE_BASED_POLICIES,
RangerConstants.MODULE_REPORTS, RangerConstants.MODULE_AUDIT,
RangerConstants.MODULE_USER_GROUPS,
RangerConstants.MODULE_GOVERNED_DATA_SHARING,
RangerConstants.MODULE_KEY_MANAGER)) {
Review Comment:
The keyadmin user does not have access to the Governed Data Sharing module.
Could you please consider removing it?
--
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]