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-community/plugin-api-permissions

v1.0.0-alpha.3

Published

Content API RBAC for Strapi — auth-provider agnostic roles and permissions

Readme

Strapi API Permissions

Content API RBAC for Strapi — auth-provider agnostic roles and permissions. This plugin gives you a role management UI in the Strapi admin and a pluggable session resolver so any authentication provider can drive your Content API access control.

[!CAUTION] This plugin is in BETA state. It is by no means considered stable and should not be used in production. If you want to contribute to its development, please contact any of the maintainers.

Features

  • ✅ Role management UI in the Strapi admin panel
  • ✅ Fine-grained permissions per content type (find, findOne, create, update, delete)
  • ✅ Plugin endpoint permissions support
  • ✅ Two default roles created on first run: Public and Authenticated
  • ✅ Pluggable session resolver — wire in any auth provider
  • ✅ Auth-provider agnostic — works standalone or paired with plugin-better-auth
  • ✅ Automatically extends your user content type with a roles relation
  • ✅ Works with Strapi v5+

Installation

npm install @strapi-community/plugin-api-permissions
# or
yarn add @strapi-community/plugin-api-permissions
# or
pnpm add @strapi-community/plugin-api-permissions

Usage

1. Register the plugin

Add the plugin to your Strapi configuration:

// config/plugins.ts
export default {
  'api-permissions': {
    enabled: true,
  },
};

2. Set the user content type (if not using plugin-better-auth)

The plugin needs to know which content type represents your users so it can count role members and reassign users when a role is deleted. If you are using plugin-better-auth, this is resolved automatically. Otherwise, set the user_uid option:

// config/plugins.ts
export default {
  'api-permissions': {
    enabled: true,
    config: {
      user_uid: 'plugin::users-permissions.user',
    },
  },
};

3. Register a session resolver

The session resolver is called on every Content API request. It receives the Koa context and must return the current user and their roles, or null for unauthenticated requests. Register it in your Strapi bootstrap:

// src/index.ts
import type { Modules } from '@strapi/strapi';

export default {
  async bootstrap({ strapi }) {
    strapi
      .plugin('api-permissions')
      .service('session')
      .registerSessionResolver(async (ctx) => {
        const token = ctx.request.headers.authorization?.replace('Bearer ', '');
        if (!token) return null;

        const session = await myAuthProvider.verifyToken(token);
        if (!session) return null;

        const user = await strapi.documents('plugin::my-auth.user').findFirst({
          filters: { id: session.userId },
        });

        const roles = await strapi.documents('plugin::api-permissions.role').findMany({
          filters: { type: session.roleType },
        }) as Modules.Documents.Document<'plugin::api-permissions.role'>[];

        return { user, roles };
      });
  },
};

Using with plugin-better-auth

When plugin-better-auth is installed alongside this plugin, the session resolver is registered automatically — no manual setup required. Just enable both plugins:

// config/plugins.ts
export default {
  'better-auth': {
    enabled: true,
  },
  'api-permissions': {
    enabled: true,
  },
};

Users authenticated through Better Auth are matched against the Authenticated role. Unauthenticated requests fall back to the Public role.

How it works

On startup the plugin:

  1. Extends your user content type with a roles manyToMany relation pointing to plugin::api-permissions.role.
  2. Registers a content-api authentication strategy with Strapi that runs on every Content API request.
  3. Seeds the database with Public and Authenticated roles if none exist yet.

On each Content API request the strategy:

  1. Calls your registered session resolver with the Koa context.
  2. Loads the permissions for the resolved role(s), falling back to the Public role for unauthenticated requests.
  3. Generates a CASL ability from those permissions and attaches it to the request.

Admin panel

Navigate to Settings → API Permissions → Roles to manage roles. From there you can:

  • Create custom roles with any combination of content type and plugin permissions.
  • Edit which actions (find, findOne, create, update, delete) are enabled per role.
  • Delete roles — users are automatically reassigned to the Public role on deletion.

[!NOTE] The Public role cannot be deleted.

Authors

License

See the LICENSE file for licensing information.