Skip to content

Unable to Apply RBAC Custom Conditions in Navigation Plugin #389

@bobbylipps

Description

@bobbylipps

Description:
I'm attempting to implement custom conditions within the Navigation plugin to restrict certain menus based on user roles. Specifically, I want to limit the menus an editor can access and modify.

I added the following custom condition in src/index.js:

const docsNavigation = {
  displayName: "Can only view docs navigation",
  name: "docs-nav-access",
  async handler(user) {
    const condition = { id: { $eq: 3 } };
    return condition;
  }
};

await strapi.admin.services.permission.conditionProvider.register(docsNavigation);

I tried applying the custom condition using various field names such as id, name, slug, etc. I navigated to the navigation editing page at /admin/plugins/navigation and can still see all menus. The custom condition is applied to the role in the Strapi admin.

Expected Behavior:
The custom condition should limit the visibility and editability of menus based on the specified condition.

Actual Behavior:
The custom condition doesn't seem to have any effect on the navigation editing page. No matter which field name I use, the condition doesn't seem to apply.

Additional Information:

  • I'm trying to achieve a scenario where editors only have access to specific menus.
  • I'm unsure if the Navigation plugin supports these custom conditions or if I'm missing something in my implementation.

Any guidance or clarification on whether the Navigation plugin supports such custom conditions would be greatly appreciated.

strapi - 4.15.0
strapi-plugin-navigation - latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions