Documentation

RoleWarden

Roles and permissions in the database, with an admin panel, for CodeIgniter 4. RoleWarden extends CodeIgniter Shield: Shield keeps users, passwords, sessions, sign-in, "remember me", tokens and the record of sign-in attempts; RoleWarden moves roles and permissions out of a config file and into tables you manage at runtime.

What you get

Requirements

RoleWarden needs Shield. An application with its own authentication and no wish to use Shield cannot use RoleWarden.

Three ideas to keep in mind

Code checks permissions, never roles

Write can('users.delete'), never "is this user an admin". Roles are only bundles of permissions that administrators rearrange in the panel; code that names a role breaks the day someone renames or splits it.

Permissions are named area.action

Lowercase, one dot: users.view, invoices.approve, documents.delete. Code refers to them by this name, never by id.

How a check is decided

  1. A deactivated user is denied everything.
  2. A permission denied to that user by an override is denied, even to a super admin.
  3. A permission granted to that user by an override is granted.
  4. A super admin is granted everything else.
  5. A permission held by one of the user's roles, directly or inherited from a parent role, is granted.
  6. Anything else is denied.

Where to start

No file of the module is meant to be edited. Everything you customise lives in your application, so an update is a replacement of the module's folder. Changes between versions are listed in CHANGELOG.md; licences of third-party code in THIRD-PARTY-LICENSES.md.