Download the PHP package serenity_technologies/admin-dashboard-guard without Composer

On this page you can find all versions of the php package serenity_technologies/admin-dashboard-guard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package admin-dashboard-guard

admin-dashboard-guard

A Laravel package that places a two-factor passphrase + password authentication wall in front of any admin-restricted page — Horizon, Telescope, Pulse, Filament, or any custom route — with zero extra database tables.


How It Works

Access to a protected page requires two sequential steps:

  1. Passphrase step — The admin provides a short-lived secret passphrase (bcrypt-hashed in the database). On success, a 10-minute session window opens.
  2. Password step — Within that window, the admin enters their account password to receive a fully-authenticated session (valid for 60 minutes by default).

Each protected page runs its own independent session, so authenticating to /horizon does not grant access to /telescope.

Generating a passphrase via Artisan emails it directly to the admin and schedules automatic revocation after a configurable delay.


Requirements

Requirement Version
PHP ^8.1
Laravel ^11.0 | ^12.0 | ^13.0
Laravel Sanctum (optional) ^3.0 | ^4.0

Sanctum is only needed if you want to accept a bearer-token as an alternative to the session flow. It is listed under suggest in composer.json and is not required by default.


Installation

1. Require the package

The service provider is auto-discovered via extra.laravel.providers in composer.json.

2. Publish the config

This creates config/admin-dashboard-guard.php.

3. Add the passphrase column to your admin model

Run the migration:

4. Configure your admin model

Set the model in .env:

Your model must implement Illuminate\Contracts\Auth\Authenticatable and have both a passphrase column (nullable, stores a bcrypt hash) and a password column.

5. Configure the auth guard

Ensure an admin guard is defined in config/auth.php:

Then set in .env:


Protecting a Page

The package registers a named middleware alias for every entry in protected_pages. The alias format is admin.{key}.

Horizon

In config/horizon.php:

Telescope

In app/Providers/TelescopeServiceProvider.php:

And add the middleware to the route group in your telescope service provider or routes/web.php:

Any Custom Route

You can protect any route or route group with the admin.{key} alias, where key matches an entry in protected_pages:


Adding a New Protected Page

Open config/admin-dashboard-guard.php and add an entry to protected_pages:

The package automatically:

protected_pages Options

Key Type Default Description
path string (key name) URL path segment (e.g. 'horizon'/horizon)
gate string\|null 'view{Key}' Gate name to define. Set null to skip.
session_prefix string (key name) Namespace prefix for session keys
passphrase_ttl int 10 Minutes the passphrase verification window is valid
session_ttl int 60 Minutes the fully-authenticated session is valid
theme_color string 'blue' Tailwind colour name used in the login views
stealth_mode bool false (global) When true, unauthenticated requests receive 404. Overrides the global default for this page.

Stealth Mode

When stealth mode is enabled the auth wall is completely invisible to unauthenticated requests. The passphrase form is never shown — every bare access attempt returns a plain 404 Not Found, exactly as if the route did not exist.

The only way in is to carry the passphrase directly in the URL query string:

A valid passphrase silently redirects to the password step as normal. A wrong passphrase also returns 404 (not 401), so nothing about the auth wall is revealed.

Enable globally (all protected pages)

Or directly in the published config:

Enable per page (overrides the global default)

Tip: Combine stealth mode with a short --delay when generating passphrases so the URL is valid only for a small window of time.


Artisan Commands

All commands are prefixed with admin-guard: to avoid collisions with the host application.

Generate a passphrase for one admin

Generates a random passphrase, bcrypt-hashes and saves it to the admin record, emails it to the admin, then queues an auto-removal job after --delay hours.

Option Default Description
--bcc= BCC address for the notification email
--length= 32 Passphrase length (minimum 16)
--delay= 1 Hours before the passphrase is automatically revoked

Example output:


Generate passphrases for all admins

Runs the single-admin flow for every record returned by the configured model. Accepts the same --bcc, --length, and --delay options.


Remove a passphrase for one admin

Immediately nulls out the passphrase column for the given admin, invalidating any active passphrase-step session.


Clear passphrases for all admins

Nulls the passphrase column for every admin that currently has one set. Prompts for confirmation unless --force is passed.

Option Description
--force Skip the confirmation prompt (useful in scripts or CI)

Incident response tip: Run admin-guard:clear-passphrases --force to instantly revoke all active passphrases if you suspect a passphrase has been compromised.


Configuration Reference

Environment Variables

Variable Default Description
ADMIN_DASHBOARD_GUARD admin Auth guard name
ADMIN_DASHBOARD_MODEL null Fully-qualified model class
ADMIN_DASHBOARD_PASSPHRASE_COLUMN passphrase Column storing the bcrypt passphrase hash
ADMIN_DASHBOARD_PASSWORD_COLUMN password Column storing the bcrypt password hash
ADMIN_DASHBOARD_SANCTUM true Enable Sanctum bearer-token fallback

Customising the Views

Publish the Blade views to override them:

Files land in resources/views/vendor/admin-dashboard-guard/:

View Purpose
passphrase-login.blade.php Step 1 — passphrase entry form
password-login.blade.php Step 2 — password entry form
emails/admin-passphrase.blade.php Passphrase notification email

Each view receives $toolName, $toolPath, and $themeColor variables.


Customising the Passphrase Email Subject

Pass a custom subject when constructing the mailable directly:


Sanctum Bearer Token Fallback

When sanctum_support is true and laravel/sanctum is installed, the middleware also accepts a valid personal-access token belonging to an instance of the configured model class. This lets programmatic/API clients access protected pages without going through the browser-based session flow.


Custom Authorization Conditions

You can define additional custom conditions to authorize an admin before allowing dashboard access. This is useful for checking user roles, statuses, or other custom criteria.

1. Global or Per-Page Config Condition Class

Create an invokable/callable class that receives the admin model, the HTTP request, and the tool name:

Then register it globally in config/admin-dashboard-guard.php:

Or configure it per-page inside the protected_pages array:

2. Runtime Callback (Closure)

Alternatively, register a closure check dynamically in your AppServiceProvider (or any service provider) using the static checkUsing method:


Security Notes


License

MIT


All versions of admin-dashboard-guard with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/routing Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/auth Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package serenity_technologies/admin-dashboard-guard contains the following files

Loading the files please wait ...