PHPackages                             potatopowered/role-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. potatopowered/role-auth

ActiveCakephp-plugin[Authentication &amp; Authorization](/categories/authentication)

potatopowered/role-auth
=======================

The RoleAuth Component aims to make authorization in CakePHP 3.x applications as simple as can be.

1.1.2(7y ago)024MITPHPPHP &gt;=5.4.16

Since Jul 30Pushed 7y ago3 watchersCompare

[ Source](https://github.com/PotatoPowered/RoleAuth)[ Packagist](https://packagist.org/packages/potatopowered/role-auth)[ RSS](/packages/potatopowered-role-auth/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (4)Versions (7)Used By (0)

RoleAuth
========

[](#roleauth)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Travis](https://camo.githubusercontent.com/d1a581863f211a15bfbacc62ac933b4ccd50423e9dd06017d707a83c2cc66bd4/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f506f7461746f506f77657265642f526f6c65417574682e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/PotatoPowered/RoleAuth)[![Codecov](https://camo.githubusercontent.com/57fc9d83cf6a116da287a736b107d3aeabc2c9e5f8658816f556b7bd96fc9266/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f506f7461746f506f77657265642f526f6c65417574682e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/PotatoPowered/RoleAuth)[![Packagist](https://camo.githubusercontent.com/5d6e8a97515d3f18c1c1fdd5a79f6ac711eb2dbc05f23d3970a4e78c11575799/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706f7461746f706f77657265642f726f6c652d617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/potatopowered/role-auth)

Description
-----------

[](#description)

The RoleAuth Component aims to make authorization in CakePHP 3.x applications as simple as can be.

Installation Guide
------------------

[](#installation-guide)

Add the component to your composer.json you can do this easily using composer itself.

```
composer require potatopowered/role-auth

```

Add the roles table using migrate.

```
bin/cake migrations status -p RoleAuth

```

Load the RoleAuth Component with the other components in the initialize function of your AppController to have it accessible in all controllers.

```
$this->loadComponent('RoleAuth.RoleAuth');

```

### Advanced Load

[](#advanced-load)

```
$this->loadComponent('RoleAuth.RoleAuth', [
  'roles_table' => 'roles',
  'admin_role' => 'Admin',
  'default_role' => 'User'
]);

```

Usage
-----

[](#usage)

*This assumes that you have `role_id` setup in the user linking to this plugins roles table.*

### Check if a user is an admin

[](#check-if-a-user-is-an-admin)

To use the RoleAuth component to check if a user is an admin you can make a call as such. The following will check the logged in users `role_id` and verify that they are an admin or not. The result is boolean.

```
$this->RoleAuth->isAdmin($this->Auth->user('role_id'));

```

### Check if a user has a specific role

[](#check-if-a-user-has-a-specific-role)

To use the RoleAuth component to check if a user is a specific role you can make a call as such. The following will check the logged in users `role_id` and verify that they have a role or not. The result is boolean.

```
$this->RoleAuth->hasRole('YourRole', $this->Auth->user('role_id'));

```

### Set all role variables

[](#set-all-role-variables)

To use the RoleAuth component to check the users role and set all role variables in one shot you can make a call as such. The following will check the logged in users `role_id` and verify that they have a role or not. The result is boolean.

```
$this->RoleAuth->setRoles($this->Auth->user());

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 78.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~84 days

Total

5

Last Release

2870d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed148c9a48c42d2cd8d439c091444df47be2ad744bab37376d4b17da07ef668c?d=identicon)[potatopowered](/maintainers/potatopowered)

---

Top Contributors

[![kaffineaddict](https://avatars.githubusercontent.com/u/1271668?v=4)](https://github.com/kaffineaddict "kaffineaddict (25 commits)")[![stosh15x](https://avatars.githubusercontent.com/u/10407579?v=4)](https://github.com/stosh15x "stosh15x (7 commits)")

---

Tags

cakephpauthorizationPotato Powered SoftwareRoleAuth

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/potatopowered-role-auth/health.svg)

```
[![Health](https://phpackages.com/badges/potatopowered-role-auth/health.svg)](https://phpackages.com/packages/potatopowered-role-auth)
```

###  Alternatives

[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

129228.6k10](/packages/dereuromark-cakephp-tinyauth)[cakedc/users

Users Plugin for CakePHP

524897.0k16](/packages/cakedc-users)[admad/cakephp-jwt-auth

CakePHP plugin for authenticating using JSON Web Tokens

160680.3k8](/packages/admad-cakephp-jwt-auth)[markstory/acl_extras

Additional tools for managing DB ACL in CakePHP applications.

155311.0k](/packages/markstory-acl-extras)[uafrica/oauth-server

OAuth Server for CakePHP 3 using the PHP League's OAuth2 Server

5172.1k](/packages/uafrica-oauth-server)[cakedc/auth

Auth objects for CakePHP

31630.0k2](/packages/cakedc-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
