damianulan/laravel-sentinel
A lightweight Laravel sentinel package that adds a configurable monitoring and guarding layer to your application. It watches key runtime signals, hooks into framework events, and helps you detect issues early so your app stays secure and observable with minimal setup.
This package layers a root/superuser permission bypass on top of Laravel's authorization stack. The 1.0.6 patch fixes how root status is evaluated during permission checks, so it's worth re-verifying any code paths that assume root users short-circuit normal permission logic.
composer require the package (1.0.6 or later, since the root check fix is the reason to be on this version), then publish any config/asset files per the package README. Confirm the service provider is auto-discovered.isRoot(), a trait, or a gate before callback). This is the single most important piece of the package and the thing 1.0.6 changed. Understand exactly what it checks: a column on the users table, a config-listed user ID, a role, or an env flag.Start in config/ and the authorization trait on your User model before touching controllers — most day-to-day issues are configuration, not code.
Root bypass as a gate before callback. The idiomatic integration is to register root handling ahead of your normal gates/policies so a root user never fails a downstream check:
Gate::before(function ($user, $ability) {
return $user->isRoot() ? true : null; // null = fall through to policies
});
Returning null (not false) is essential — false would deny everything for non-root users. Make sure your root check runs before per-ability policies, not inside them.
Policy-level integration. Where you prefer explicit checks, resolve root inside each policy's before method rather than repeating it in every ability method:
public function before(User $user)
{
return $user->isRoot() ? true : null;
}
Blade and middleware usage. Permission checks in views and route middleware should route through the same package helpers so the root logic is consistent. Avoid re-implementing isRoot() inline — one implementation, one place to fix (exactly the class of bug 1.0.6 landed).
Testing patterns. Write three-way test cases for every protected ability: root user, permitted user, unpermitted user. A root-user test that also has the ability granted is a false negative — it passes even when the root bypass is broken. Always test root with zero explicit permissions.
Cache-aware checks. If your permission set is cached per user, ensure the root flag is invalidated alongside permission caches when a user's role or root status changes, otherwise stale privilege persists after a downgrade.
before, a more specific gate or an earlier-registered before callback can win first. Register root handling last among before callbacks so it isn't shadowed — but verify against your Laravel version's precedence, since before callbacks run in registration order and the first non-null result wins.false vs null. The most common self-inflicted bug: returning false from a root before for non-root users denies the entire application. Always null.null/0 ID coercion — an empty or zero user ID matching a loosely-typed config comparison is a classic.^1.0.6 rather than ^1.0 so downstream installs don't resolve to a pre-fix build in a lockfile-less environment.How can I help you explore Laravel packages today?