handersonsilva/laravel-access

A package to manage access to your Laravel application per environment

1.0.6 2025-01-16 02:25 UTC

This package is auto-updated.

Last update: 2025-09-16 04:12:22 UTC


README

Total Downloads Latest Stable Version License

About Laravel Access

Laravel Access is a package that provides a simple way to manage access control per environments in Laravel applications.

Requirements

  • PHP >= 8.3
  • Laravel >= 10.0

Services required

  • Email Server (any driver)
  • Cache (any driver)

Installation

Add the package to your project

composer require handersonsilva/laravel-access

Publish the package in your project

php artisan vendor:publish --provider="SecurityTools\LaravelAccess\Providers\AccessServiceProvider"

Middleware

Add the following code to the app/Http/Kernel.php file on the global middleware

protected $middleware = [
        \SecurityTools\LaravelAccess\Middleware\AccessMiddleware::class,
        ...
];

Run the initial configuration

php artisan access:install

Configuration

Add environments in the .env file

# Access  
ACCESS_ENABLE=true # Enable access
ACCESS_SECRET=your_secret_key # Generate any secret key 

Block access to the application per environment

Add the following code to the config/access.php file to block access to the application in the environments you want.

'block_env' => ['local'], # Environments to block access to the application ex: ['local', 'staging', 'production']

Block access to the application per route prefix

'block_prefixes' => ['/admin'], # Prefixes to block access to the application ex: ['/admin', '/private']

Define the default route to redirect the user after validation

'redirect_prefix' => '/admin',# Default route to redirect the user after validation default: '/'

See the complete configuration in the config/access.php file

Auto Login

To enable auto login, add the following code to the .env file

# Access  
ACCESS_AUTO_LOGIN=true # Enable auto login
ACCESS_GUARD=web # Guard to be used for authentication

When auto login is enabled, the user will be automatically authenticated to the application without the need to enter the login and password.

Security Vulnerabilities

If you discover a security vulnerability within Laravel Access, please send an e-mail to Handerson Silva via handersonsylva@gmail.com. All security vulnerabilities will be promptly addressed.

License

The Laravel Access framework is open-sourced software licensed under the MIT license.