tkaratug/laravel-domain-whitelist

A domain wwhitelist checker middleware.
1,227 13
Install
composer require tkaratug/laravel-domain-whitelist
Latest Version:1.2.0
PHP:^7.4|^8.0|^8.1|^8.2
License:MIT
Last Updated:Feb 19, 2023
Links: GitHub  ·  Packagist
Maintainer: tkaratug

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads


Introduction

This package contains a middleware to check whether the origin domain is in the whitelist. If not it blocks the request.


Installation

You can install the package via composer:

composer require tkaratug/laravel-domain-whitelist

You can publish the config file with:

php artisan vendor:publish --provider="Tkaratug\LaravelDomainWhitelist\LaravelDomainWhitelistServiceProvider" --tag="domain-whitelist-config"

This is the contents of the published config file:

return [
    /*
    |---------------------------------------------
    | Domains to allow
    | Leave empty to allow all requests
    |---------------------------------------------
    */
    'domains' => [
        //'*.example.com',
        //'example.com',
    ],

    /*
    |---------------------------------------------
    | Paths to exclude
    |---------------------------------------------
    */
    'excludes' => [
        //'/api/posts',
    ],
];

Usage

Packages comes with DomainWhitelist middleware. You can register it in $routeMiddleware in app/Http/Kernel.php file:

protected $routeMiddleware = [
    // ...
    'domain_whitelist' => \Tkaratug\LaravelDomainWhitelist\Middlewares\DomainWhitelist::class,
];

Use the middleware in any of your routes.

Route::middleware('domain_whitelist')->get('/', [HomeController::class, 'index']);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

tkaratug/livewire-smart-table

An advanced datatable component for Laravel Livewire

2,365 92
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

637,827,751 9,703
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609

Version History

Version Released PHP Laravel License
1.2.0 ^7.4|^8.0|^8.1|^8.2 ^8.0|^9.0|^10.0 MIT
1.1.0 ^7.4|^8.0|^8.1 ^8.0|^9.0 MIT
1.0.0 ^7.4 || ^8.0 ^8.37 MIT