Permissions Roles, permissions, and policies for NetPress
NetPressv0.1.7 Permissionsv0.2.3 Docsv0.2.2
Overview Installation Policies Auth Guard

Implementation-synced docs

Laravel-style roles, permissions, policies, and AuthGuard middleware for NetPress applications — built on top of the shared runtime and polymorphic relation primitives that ship with the framework.

Permissions banner

Quick install

npm install @admicaa/netpress-permissions
npm run artisan -- vendor:publish \
  --provider=NetpressPermissionsServiceProvider
npm run migrate
NetPress Permissions Docs

NetPress Permissions

@admicaa/netpress-permissions is the Laravel-style authorization package for NetPress. It ships roles, permissions, polymorphic assignments, an Express-friendly AuthGuard middleware, and a publisher that wires everything into your application with a single command.

Authentication guards themselves live in NetPress core under Auth from @admicaa/netpress. This package sits one layer above that and focuses on authorization.

For the core framework runtime, guards, policies, controllers, and the shared can() helper, start with @admicaa/netpress and the main framework project: <https://github.com/admicaa/netpress>

What You Get

  • Role and Permission Eloquent-style models backed by Knex
  • HasRoles and HasPermissions traits composable through Authorizable(BaseModel)
  • Polymorphic assignments so any model can carry roles or direct permissions
  • An AuthGuard middleware that wraps policy-aware ability and permission checks for Express 5 routes
  • Permission groups for clean UI display logic (e.g. posts, users, billing)
  • registerPolicy integration for class-based resource policies
  • A vendor:publish flow that drops a config file, a migration, and a service provider into your app

When To Reach For It

You need NetPress Permissions when your app has more than a couple of binary role checks and you want a predictable, test-friendly pattern for:

  • assigning users to roles, and roles to permissions;
  • granting direct per-model permissions without creating a role first;
  • resolving resource policies and permission names through the same can() helper;
  • guarding Express routes with a one-liner (AuthGuard.can('posts.publish'));
  • separating permissions into groups so your admin UI can render them sanely.

A Thirty Second Taste

import { BaseModel } from '@admicaa/netpress';
import {
  Authorizable,
  Permission,
  Role,
} from '@admicaa/netpress-permissions';

class User extends Authorizable(BaseModel) {
  static table = 'users';
}

const editor = await Role.findOrCreate('editor');
const publish = await Permission.findOrCreate('posts.publish', { group: 'posts' });

await editor.givePermissionTo(publish);

const user = await User.create({ name: 'Amina' });
await user.assignRole(editor);

await user.can('posts.publish'); // true

Where To Next