How It Works
The package works by adding a middleware to Filament's routing system. When a request is made to access the admin panel, the middleware checks if the provided secret key matches the one set in the
.env file. If the secret key matches, the request is allowed, and the admin panel is accessible. Otherwise, a 404 page is displayed, indicating that access is restricted.
To get started, you'll need to install the "Filament Access Secret" package via Composer. Open your terminal and run the following command:
composer require dasundev/filament-access-secret
If you wish to customize the configuration options, you can publish the package's config file using the following command:
php artisan vendor:publish --tag="filament-access-secret-config"
Once you've installed the package, open your .env file and add the following key-value pair:
secret with the desired secret key you want to use. This secret key will serve as the access token to Filament.
To access Filament, you need to append the secret key to the Filament URL. Here's an example:
By including the secret key in the URL, you ensure that only users who have the correct access token can access the Filament admin panel.
Disabling Secret Access
If you want to disable the secret access temporarily or permanently, you have two options:
- Keep the
FILAMENT_ACCESS_SECRET_KEYvalue empty in your .env file.
- Delete the
FILAMENT_ACCESS_SECRET_KEYkey from the .env file.
Either of these options will disable the secret access requirement, allowing anyone to access the Filament admin panel without providing a secret key.
Adding an access secret to your Filament installation provides an additional layer of security, ensuring that only authorized users can access the admin panel. With the "Filament Access Secret" package, you can easily require a secret key in the URL to secure your Filament access. By following the installation and usage instructions outlined in this blog post, you can enhance the security of your Filament-powered application and protect sensitive data.
Remember, security is crucial, and taking proactive steps to safeguard your admin panel is a wise decision.
Stay secure and enjoy using Filament! 💛