Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

FINERACT-3242: Check bulk import permissions for groups and centers - #7198

Open
adamsaghy wants to merge 1 commit into
apache:developfrom
adamsaghy:FINERACT-3242-group-center-import-permissions
Open

adamsaghy wants to merge 1 commit into
apache:developfrom
adamsaghy:FINERACT-3242-group-center-import-permissions

Conversation

@adamsaghy

Copy link
Copy Markdown
Contributor

Description

JIRA: https://issues.apache.org/jira/browse/FINERACT-3242 (follow-up to #7082, which covered offices and staff)

Group and center bulk imports dispatch GroupCreateCommand, CenterCreateCommand and CalendarCreateCommand through the typed CommandDispatcher (since FINERACT-2832 / FINERACT-2296). The dispatcher does not check the task permission that the legacy command pipeline checked for each row. POST /groups/uploadtemplate and POST /centers/uploadtemplate are deliberately left out of ApiAuthorizationRules (GROUPING_ID) because the import handler is supposed to authorize the rows. Without a check there, any authenticated user could create groups, centers and their collection meetings by bulk import.

Changes:

  • GroupImportHandler / CenterImportHandler check ALL_FUNCTIONS or CREATE_GROUP / CREATE_CENTER once, before any row is read. A user without the permission gets every row that is not yet imported marked Creation failed, with "User has no authority to create groups/centers" in the failure column, and nothing is dispatched. A row whose group or center was already created by an earlier run (Meeting failed) keeps that status and its id, so a later run with the permission does not create it again.
  • A row with a collection meeting also needs ALL_FUNCTIONS or CREATE_CALENDAR. Without it, the group or center is created and the row ends as Meeting failed with its id. This is what the legacy pipeline did, and what the handlers' existing progress levels model.
  • New ImportHandlerUtils.rejectUnauthorizedRows(...) overload for templates that report errors in a separate failure column. It counts rows through BulkImportTemplateLayout, like FINERACT-3242: Add per-row permission checks to office and staff bulk… #7082.
  • Activation and client association are unchanged. The write service already checks ACTIVATE_GROUP, ACTIVATE_CENTER and ASSOCIATECLIENTS_GROUP (validateRollbackCommand).

Tests:

  • GroupImportHandlerPermissionTest and CenterImportHandlerPermissionTest (5 each) use real Role/Permission/AppUser objects. They cover: denied (including a malformed row, a Meeting failed row and an already imported row), CREATE_* only, CREATE_* without CREATE_CALENDAR for a row with a meeting, CREATE_* plus CREATE_CALENDAR, and ALL_FUNCTIONS.
  • BulkImportPermissionTest (integration): a user without permissions uploads a group / center, the row fails and nothing is created; after CREATE_GROUP / CREATE_CENTER is granted, the same user imports it.

Locally: Spotless, checkstyle and modernizer are clean, and all bulkimport.importhandler unit tests pass. The integration tests compile; they run in CI.

Checklist

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes (no API changes)
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.
  • If merging this PR resolves a JIRA issue, I will mark that issue as resolved and set "Fix Version/s" appropriately.
  • I followed the AI Policy.

Group and center bulk imports dispatch GroupCreateCommand,
CenterCreateCommand and CalendarCreateCommand through the typed
CommandDispatcher (FINERACT-2832, FINERACT-2296), which does not check
the task permission the legacy command pipeline checked per row. The
groups and centers upload endpoints are left out of the URL rules
because the import handler authorizes the rows, so any authenticated
user could create groups, centers and their meetings by import.

- GroupImportHandler / CenterImportHandler check ALL_FUNCTIONS or
  CREATE_GROUP / CREATE_CENTER before reading any row. Without it, every
  row not yet imported fails with "Creation failed" and an authority
  message, and nothing is dispatched. A row whose group or center an
  earlier run created ("Meeting failed") keeps that status and its id.
- A row with a collection meeting also needs ALL_FUNCTIONS or
  CREATE_CALENDAR. Without it the group or center is created and the row
  ends as "Meeting failed", as the legacy pipeline did.
- Activation and client association keep their existing checks in the
  write service (ACTIVATE_GROUP, ACTIVATE_CENTER, ASSOCIATECLIENTS_GROUP).

Assisted-By: claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant