webparking/laravel-limited-access

Limited access for Laravel
1,080 33
Install
composer require webparking/laravel-limited-access
Latest Version:2.0.0
PHP:^7.4|^8.0
License:MIT
Last Updated:Jan 28, 2022
Links: GitHub  ·  Packagist
Maintainer: JeroenVanOort

Tests

This package provides an easy access-restricting layer for your Laravel application.

With limited access you can block or allow certain ip addresses on application level. You could also define a list of access codes to distribute between trusted users.

A few use-cases are:

  • Set access codes for an application that is not ready to go live yet. For example an acceptance environment.
  • Block malicious users from using your application. Simply add their ip addresses to the blocked list.
  • Making a private application only a few users can access. Just block all ip addresses except your own.

Here's an example of what your login could look like when using access codes

screenshot

Installation

Add this package to composer.

composer require webparking/laravel-limited-access

Publish assets:

php artisan vendor:publish --provider="Webparking\LimitedAccess\ServiceProvider" --tag="public"

Optional steps

Publish config:

php artisan vendor:publish --provider="Webparking\LimitedAccess\ServiceProvider" --tag="config"

Publish translations:

php artisan vendor:publish --provider="Webparking\LimitedAccess\ServiceProvider" --tag="lang"

Or just publish all the things:

php artisan vendor:publish --provider="Webparking\LimitedAccess\ServiceProvider"

Usage

To use this package you need to enable it by either enabling the package in the config or adding the following to your .env file.

LIMITED_ACCESS_ENABLED=true

To add access codes add the following key to your .env file and specify your access codes in a comma separated list.

LIMITED_ACCESS_CODES=comma,separated,access,codes

Blocking/Ignoring IP addresses

In config/limited-access you can add single IP addresses or IP address ranges in CIDR format.

Example:

return [
    'block_ips' => [
        '192.168.1.0/24',
        '66.66.66.66', // 66.66.66.66/32 is equivalent
        '2000:ffff::1',
        '2000:ffff/64',
    ],

    'ignore_ips' => [
        '11.22.33.44',
        '10.0.0.0/8',
        '127.0.0.1',
        '::1',
    ],
];

Blocked IPs take priority over ignored IPs, so adding the same address or range to both arrays will cause the given IP to be blocked.

You can leave both of these arrays empty if you wish for everyone to be prompted for a password.

Licence and Postcardware

This software is open source and licensed under the MIT license.

If you use this software in your daily development we would appreciate to receive a postcard of your hometown.

Please send it to: Webparking BV, Cypresbaan 31a, 2908 LT Capelle aan den IJssel, The Netherlands

Related Packages

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

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

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444