Skip to content

fix: removed user membership access filter based on current user memb…#29

Open
SeanBerrieHRI wants to merge 1 commit intomainfrom
bug/FDP-144
Open

fix: removed user membership access filter based on current user memb…#29
SeanBerrieHRI wants to merge 1 commit intomainfrom
bug/FDP-144

Conversation

@SeanBerrieHRI
Copy link
Copy Markdown

@SeanBerrieHRI SeanBerrieHRI commented Mar 31, 2026

Description

Actual:
When managing access for a metadata entity (e.g., a Dataset), the role selection dropdown is being limited to only those roles already held by existing members.

For example, if the only person with access to a Dataset is an Owner, the user can only invite new users as an Owner. The User role, despite being a valid system role, is hidden because no current member holds it.

Expected:
When managing access for a metadata entity (e.g., a Dataset), the role selection dropdown should show all available memberships for selection.

Cause:

In the FairDataPoint-Client > src > components > EntitySettings > Index.vue:

The memberships list is filtered based on the memberships provided to user entities in the list.

  async fetchData(): Promise<void> {
    .....
          this.memberships = this.createMemberships(memberships.data)
    .....
  }
    
    createMemberships(memberships: Array<any>): Array<any> {
      return memberships.filter((m) => _.includes(m.allowedEntities, this.config.uuid))
    },

fixes #
Removing the filter function allows for all the available Memberships to be shown, allowign you to assign any role to any user.

  async fetchData(): Promise<void> {
    .....
          this.memberships = membership.data
    .....
  }

Summary by Sourcery

Bug Fixes:

  • Fix role dropdown so it lists all valid memberships for an entity, not just those currently assigned to existing members.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 31, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes over-restrictive filtering of available memberships in EntitySettings so that all roles returned from the backend are shown in the role selection dropdown, and cleans up the now-unused helper.

Sequence diagram for fetching memberships in EntitySettings

sequenceDiagram
  actor User
  participant EntitySettingsComponent
  participant BackendAPI

  User->>EntitySettingsComponent: Open access management view
  EntitySettingsComponent->>BackendAPI: GET entity, members, users, memberships
  BackendAPI-->>EntitySettingsComponent: entity, members, users, memberships
  EntitySettingsComponent->>EntitySettingsComponent: buildGraph(entity)
  EntitySettingsComponent->>EntitySettingsComponent: sort members
  EntitySettingsComponent->>EntitySettingsComponent: createUsers(users, members)
  EntitySettingsComponent->>EntitySettingsComponent: set memberships = memberships.data
  EntitySettingsComponent->>EntitySettingsComponent: set inviteForm.membershipUuid = first memberships entry
  EntitySettingsComponent-->>User: Render dropdown with all memberships from backend
Loading

Class diagram for EntitySettings component membership handling

classDiagram
  class EntitySettingsComponent {
    +any config
    +Array~any~ members
    +Array~any~ users
    +Array~any~ memberships
    +any inviteForm
    +any status
    +any subject
    +any breadcrumbs
    +fetchData() Promise~void~
    +buildGraph(entityData any) void
    +createUsers(usersData Array~any~, members Array~any~) Array~any~
    +submitInvite() Promise~void~
  }

  class BackendAPI {
    +getEntityData(uuid string) Promise~any~
    +getMembers(uuid string) Promise~Array~any~~
    +getUsers() Promise~Array~any~~
    +getMemberships() Promise~Array~any~~
  }

  EntitySettingsComponent --> BackendAPI : uses

  class Membership {
    +string uuid
    +string name
    +Array~string~ allowedEntities
  }

  EntitySettingsComponent "*" --> "*" Membership : displays_all_from_backend

  %% Removed behavior (for comparison of structure only)
  class RemovedBehavior {
    -createMemberships(memberships Array~any~) Array~any~
  }

  EntitySettingsComponent ..> RemovedBehavior : helper_removed
Loading

File-Level Changes

Change Details Files
Use full memberships list from API response instead of filtering by current entity, so all roles are available in the invite form dropdown.
  • Assign memberships from the raw memberships API response directly in fetchData instead of passing through a filtering helper.
  • Remove the createMemberships helper method that filtered memberships by allowedEntities and the current entity UUID.
  • Keep initial inviteForm.membershipUuid selection logic but now based on the unfiltered memberships list.
src/components/EntitySettings/index.vue

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • By removing the createMemberships filter entirely, this.memberships may now include roles that aren’t valid for the current entity type; consider ensuring the backend already scopes memberships.data appropriately or reintroducing a more precise, entity-safe filter that still shows all valid roles.
  • With inviteForm.membershipUuid now defaulting to the first unfiltered membership, it might be safer to explicitly pick a sensible default role (e.g., by name or priority) rather than relying on array order, to avoid accidentally defaulting to an overly privileged membership.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- By removing the `createMemberships` filter entirely, `this.memberships` may now include roles that aren’t valid for the current entity type; consider ensuring the backend already scopes `memberships.data` appropriately or reintroducing a more precise, entity-safe filter that still shows all valid roles.
- With `inviteForm.membershipUuid` now defaulting to the first unfiltered membership, it might be safer to explicitly pick a sensible default role (e.g., by name or priority) rather than relying on array order, to avoid accidentally defaulting to an overly privileged membership.

## Individual Comments

### Comment 1
<location path="src/components/EntitySettings/index.vue" line_range="157" />
<code_context>
         this.members = _.orderBy(members.data, ['user.firstName', 'user.lastName'], ['asc'])
         this.users = this.createUsers(users.data, this.members)
-        this.memberships = this.createMemberships(memberships.data)
+        this.memberships = memberships.data
         this.inviteForm.membershipUuid = _.get(this.memberships, '0.uuid')
         this.breadcrumbs = this.config.createBreadcrumbsWithSelf(meta.data.path, this.subject)
</code_context>
<issue_to_address>
**🚨 question (security):** Dropping the `allowedEntities` filter changes which memberships are available and may widen access scope.

`createMemberships` previously limited `this.memberships` to entries whose `allowedEntities` included `this.config.uuid`. Using `memberships.data` directly means the UI (and default `inviteForm.membershipUuid`) may now surface memberships for other entities. Unless the backend enforces the same entity constraint, this could allow invites with unintended memberships. If expanding scope is intentional, can you confirm the server is enforcing the necessary entity-level checks so the client-side filter is truly redundant?
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

this.members = _.orderBy(members.data, ['user.firstName', 'user.lastName'], ['asc'])
this.users = this.createUsers(users.data, this.members)
this.memberships = this.createMemberships(memberships.data)
this.memberships = memberships.data
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 question (security): Dropping the allowedEntities filter changes which memberships are available and may widen access scope.

createMemberships previously limited this.memberships to entries whose allowedEntities included this.config.uuid. Using memberships.data directly means the UI (and default inviteForm.membershipUuid) may now surface memberships for other entities. Unless the backend enforces the same entity constraint, this could allow invites with unintended memberships. If expanding scope is intentional, can you confirm the server is enforcing the necessary entity-level checks so the client-side filter is truly redundant?

@@ -184,9 +183,6 @@ export default defineComponent({
fullName: `${u.firstName} ${u.lastName}`,
})), ['firstName', 'lastName'], ['asc'])
},
Copy link
Copy Markdown

@hcvdwerf hcvdwerf Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks too broad. The current code filters memberships by allowedEntities, and the backend still returns that field with entity-specific values. With the local API, Data Provider is only allowed for Catalog, but this PR would also show it for Dataset, Distribution, and Data Service. So this removes a real guard rather than fixing the underlying issue. Can we confirm whether allowedEntities is still authoritative before merging this?

Suggestion:
this.memberships = memberships.data.filter((m) => !Array.isArray(m.allowedEntities) || m.allowedEntities.length === 0 || m.allowedEntities.includes(this.config.uuid) )

Copy link
Copy Markdown

@hcvdwerf hcvdwerf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check comment

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.

2 participants