|
reported by Sander van der Heyden on dev list
We are currently facing some issues around the maker checker functionality, that was working a long time ago, but has been broken since. As part of https://mifosforge.jira.com/browse/MIFOSX-1364 _checker was added to each action_name in the permissions table. This solved some UI issues for Guarav, but also broke existing functionality to use the maker-checker system to approve certain actions.
In the code that retrieves the makercheckers, if the user is not the superuser, it grabs the entity_name, action_name using the permission code. But because the action_name now has _CHECKER appended this no longer works correctly.
Snapshot from AuditReadPlatformServiceImpl.java:
public Collection<AuditData> retrieveEntries(final String useType, final String extraCriteria, final boolean includeJson) {
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException( "error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
final AppUser currentUser = this.context.authenticatedUser(); final String hierarchy = currentUser.getOffice().getHierarchy();
final AuditMapper rm = new AuditMapper(); String sql = "select " + rm.schema(includeJson, hierarchy);
Boolean isLimitedChecker = false; if (useType.equals("makerchecker")) { if (currentUser.hasNotPermissionForAnyOf("ALL_FUNCTIONS", "CHECKER_SUPER_USER")) { isLimitedChecker = true; }
}
if (isLimitedChecker) { sql += " join m_permission p on p.action_name = aud.action_name and p.entity_name = aud.entity_name and p.code like '%\\_CHECKER'" + " join m_role_permission rp on rp.permission_id = p.id" + " join m_role r on r.id = rp.role_id " + " join m_appuser_role ur on ur.role_id = r.id and ur.appuser_id = " + currentUser.getId(); }
sql += extraCriteria;
To fix this issue we have now adjusted it to read:
if (isLimitedChecker) { sql += " join m_permission p on REPLACE(p.action_name, '_CHECKER', '') = aud.action_name and p.entity_name = aud.entity_name and p.code like '%\\_CHECKER'" + " join m_role_permission rp on rp.permission_id = p.id" + " join m_role r on r.id = rp.role_id " + " join m_appuser_role ur on ur.role_id = r.id and ur.appuser_id = " + currentUser.getId(); }
sql += extraCriteria;
This has solved the issue for us locally, but before reporting a bug and committing wanted to check if this has cropped up before or has any potential sideeffects?
Thanks, Sander
|