npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

strapi-rbac-component-manager

v1.0.1

Published

This plugin provides a centralized role-based access control layer for managing component configurations within Strapi.

Readme

Strapi RBAC Component Manager

A Strapi 5 plugin that provides centralized role-based access control for managing component asset configurations. It allows administrators to define default images at a global level for reuse across multiple component variants, while supporting per-entry overrides when individual customization is needed.

Overview

Some component variants (e.g., a Banner with type "text only") intentionally hide their image fields in the CMS — the image is managed centrally rather than per-entry. This plugin solves that by providing:

  • Global Asset Mappings — set a single default image for a component + variant combination that applies everywhere
  • Asset Overrides — assign a custom image to a specific component instance on a specific entry, overriding the global default

The BFF (Backend for Frontend) layer queries these records and resolves the correct image: override → global default → null.

Features

  • Global default image assignment per component variant
  • Per-entry override capability for one-off customizations
  • Dynamic component introspection (auto-discovers components with type enum fields)
  • Admin settings page with two-tab UI (Global Defaults / Overrides)
  • Cascading dropdown UX for overrides (Collection → Entry → Component Instance → Image)
  • RBAC-gated access with custom permissions
  • Multi-domain plugin compatible (domain-scoped data segregation)
  • Lifecycle hooks for cascade-deleting overrides when entries are removed
  • REST content-type API endpoints for BFF consumption

Installation

The plugin is located at src/plugins/strapi-rbac-component-manager and registered in config/plugins.ts:

// config/plugins.ts
'strapi-rbac-component-manager': {
  enabled: true,
  resolve: './src/plugins/strapi-rbac-component-manager',
},

After registering, restart Strapi. The plugin will automatically:

  • Create the database tables (global_asset_mappings, asset_overrides)
  • Register its admin settings page
  • Register RBAC permissions

Building

cd src/plugins/strapi-rbac-component-manager
npm run build

The plugin must be rebuilt after any source changes. Strapi loads the compiled dist/ output.

Admin UI

The plugin adds a Component Manager section under Settings in the Strapi admin panel.

Global Defaults Tab

Manage default images for component variants.

  1. Click Add Mapping
  2. Select a Component from the dropdown (auto-populated from Strapi's component registry)
  3. Select a Variant (enum values from the component's type field)
  4. Upload or select a Default Image from the Media Library
  5. Click Create

Each component + variant combination can have one global default image. The table shows all configured mappings with thumbnail previews.

Overrides Tab

Assign custom images to specific component instances, overriding the global default.

  1. Click Add Override
  2. Select a Collection (content types with component fields)
  3. Select an Entry from that collection
  4. Select a Component Instance (shows label like: Banner — "Welcome" (text only))
  5. Upload or select an Override Image
  6. Click Create

Overrides are independent of global defaults — they can exist without a corresponding global mapping.

Permissions

The plugin registers two RBAC permissions:

| Permission | Description | |-----------|-------------| | plugin::strapi-rbac-component-manager.settings.read | View global defaults and overrides | | plugin::strapi-rbac-component-manager.settings.update | Create, update, and delete mappings/overrides |

Super Admins have access by default. Grant these to other roles via Settings > Roles.

API Endpoints

Admin Routes (requires admin auth)

| Method | Path | Description | |--------|------|-------------| | GET | /strapi-rbac-component-manager/introspect/components | List components with type enum fields | | GET | /strapi-rbac-component-manager/global-asset-mappings | List all global mappings | | POST | /strapi-rbac-component-manager/global-asset-mappings | Create a mapping | | PUT | /strapi-rbac-component-manager/global-asset-mappings/:id | Update a mapping | | DELETE | /strapi-rbac-component-manager/global-asset-mappings/:id | Delete a mapping | | GET | /strapi-rbac-component-manager/asset-overrides | List all overrides | | POST | /strapi-rbac-component-manager/asset-overrides | Create an override | | PUT | /strapi-rbac-component-manager/asset-overrides/:id | Update an override | | DELETE | /strapi-rbac-component-manager/asset-overrides/:id | Delete an override | | GET | /strapi-rbac-component-manager/collections | List content types with components | | GET | /strapi-rbac-component-manager/collections/:uid/entries | List entries for a content type | | GET | /strapi-rbac-component-manager/entries/:uid/:entryId/components | List component instances |

Content API Routes (for BFF consumption)

| Method | Path | Description | |--------|------|-------------| | GET | /api/strapi-rbac-component-manager/global-asset-mappings | Query global mappings | | GET | /api/strapi-rbac-component-manager/asset-overrides | Query overrides |

These support Strapi's standard filters query parameter:

GET /api/strapi-rbac-component-manager/global-asset-mappings?filters[componentUid]=sections.banner&filters[variantValue]=text only
GET /api/strapi-rbac-component-manager/asset-overrides?filters[contentTypeUid]=api::page.page&filters[entryId]=abc123

BFF Resolution Logic

The BFF should implement this resolution order:

1. Check asset-overrides for this specific component instance
   → If found, use override.image
2. Check global-asset-mappings for this component + variant
   → If found, use mapping.image
3. No image available (null)

Example BFF query flow:

// 1. Try override first
const override = await fetchOverride({
  contentTypeUid: 'api::page.page',
  entryId: page.documentId,
  componentInstanceId: banner.id,
});

if (override?.image) return override.image;

// 2. Fall back to global default
const globalDefault = await fetchGlobalMapping({
  componentUid: 'sections.banner',
  enumField: 'type',
  variantValue: banner.type, // e.g. "text only"
});

if (globalDefault?.image) return globalDefault.image;

// 3. No image
return null;

Data Model

Global Asset Mapping

| Field | Type | Description | |-------|------|-------------| | componentUid | string | Component identifier (e.g. sections.banner) | | enumField | string | The enum attribute name (always type for now) | | variantValue | string | The enum value (e.g. text only) | | image | media | Single image from the Media Library |

Unique constraint: componentUid + enumField + variantValue

Asset Override

| Field | Type | Description | |-------|------|-------------| | contentTypeUid | string | Content type (e.g. api::page.page) | | entryId | string | Document ID of the entry | | componentInstanceId | integer | Strapi's internal component row ID | | componentUid | string | Component identifier (e.g. sections.banner) | | image | media | Single image from the Media Library |

Unique constraint: componentInstanceId

Multi-Domain Compatibility

This plugin is fully compatible with the @sensinum/strapi-plugin-multi-domain plugin:

  • Records are domain-scoped via the _domain_lnk join tables
  • Mappings created on domain A are not visible on domain B
  • The plugin reads the current domain from the request context
  • Domain links are automatically created when records are created through the admin UI

See PLUGIN-DEVELOPMENT-WITH-MULTI-DOMAIN.md in the project root for technical details on the integration pattern.

Lifecycle Hooks

  • Entry deletion cascade: When a content entry is deleted, all asset-override records referencing that entry are automatically removed via a lifecycle hook registered in the plugin's bootstrap phase.

Architecture Notes

  • Content type schemas are hidden from the Content Manager and Content-Type Builder (visible: false)
  • Draft and publish is disabled on both content types (draftAndPublish: false)
  • The introspection service reads strapi.components at runtime — no configuration needed when adding new components
  • Only the type enumeration field is surfaced in the UI (extensible to other enum fields in the future via the stored enumField column)
  • The plugin does not modify any existing component schemas

Extending

The architecture supports future extensions:

  • Additional asset types: Add video, icon, or other media fields to the mapping schema
  • Additional enum fields: The UI currently only shows type but enumField is stored, so supporting other discriminator enums requires only a UI change
  • Content-manager integration: A future iteration could inject indicators into the edit view showing which components use global defaults vs overrides