Custom Guards
Register custom authentication drivers (e.g., JWT, HMAC, LDAP) via auth()->extend():
// Register a custom guard
auth()->extend('jwt', fn() => new \App\Authentication\Guards\JwtGuard());
// Use it explicitly
if (auth()->guard('jwt')->check()) {
$user = auth()->guard('jwt')->user();
}Setting a Default Guard
You can set your custom guard as default in app/Config/Auth.php:
public string $defaultGuard = 'jwt';Token Abilities & Scopes
When using token-based guards (such as Personal Access Tokens or API guards), you can inspect token permissions and scopes:
$user = auth()->user();
// Check if current token has permission
if ($user->tokenCan('reports:export')) {
// Perform export
}
// Check abilities using fluent helper
if ($user->can('orders:write')) {
// Process write
}Revoking Tokens
// Revoke current request token
$user->currentAccessToken()->delete();
// Revoke all tokens for user
$user->tokens()->delete();Token Prefix & Formatting
You can customize how personal access tokens look across your organization. By default, tokens are prefixed with jengo_pat_, but you can customize this in app/Config/Auth.php:
namespace Config;
use Jengo\Auth\Config\Auth as BaseAuth;
class Auth extends BaseAuth
{
/**
* Personal Access Token prefix (e.g., 'acumen_pat_', 'acumen/pat/', 'myapp_token_').
*/
public string $tokenPrefix = 'acumen_pat_';
}You can also pass an optional prefix override directly when issuing tokens programmatically:
$tokenResult = auth()->createTokenFor($user, 'Billing Sync', ['billing:read'], null, 'acumen_api_');
echo $tokenResult->plainTextToken; // e.g. 'acumen_api_...'Custom Branding & Business Metadata
Customize application branding, company info, and logos across HTML views, notifications, and Inertia SPA props:
namespace Config;
use Jengo\Auth\Config\Auth as BaseAuth;
class Auth extends BaseAuth
{
public array $branding = [
'name' => 'Acumen',
'logo' => 'https://example.com/logo.svg',
'companyName' => 'Acumen Technologies Inc.',
];
}Brand in Frontend & Inertia Props
When using InertiaModifier or inspecting AuthResponseData::toArray(), branding metadata is automatically delivered in the payload:
{
"action": "login.view",
"status": "success",
"brand": {
"name": "Acumen",
"logo": "https://example.com/logo.svg",
"companyName": "Acumen Technologies Inc."
}
}