Access control middleware for Slim framework

Overview

Slim Access

Access control middleware for Slim framework.

Supported formats

  • IPv4 and IPv6 addresses
  • CIDR notation
  • all keyword

Installation

composer require abouvier/slim-access

Usage

Only accept requests from localhost and the 192.168.1.0/24 subnet (except for 192.168.1.42):

use \Slim\Middleware\Access;
// ...
$app = new \Slim\Slim();
// ...
$app->add(new Access([
	'callback' => function () use ($app) {
		$app->halt(403, 'You Shall Not Pass!!!');
	},
	'list' => [
		'::1' => Access::ALLOW,
		'127.0.0.1' => Access::ALLOW,
		'192.168.1.42' => Access::DENY,
		'192.168.1.0/24' => Access::ALLOW,
		'all' => Access::DENY // optional as "all" is already denied by default
	]
]));
// ...
$app->run();

or:

$app = new \Slim\Slim();
// ...
$access = new \Slim\Middleware\Access([
	'callback' => function () use ($app) {
		$app->halt(403, 'You Shall Not Pass!!!');
	}
]);
$access->allow('::1')->allow('127.0.0.1')->deny('192.168.1.42')->allow('192.168.1.0/24')->deny('all');
$app->add($access);
// ...
$app->run();
You might also like...
REST APIs using Slim framework. Implemented all CRUD operations on the MySql database
REST APIs using Slim framework. Implemented all CRUD operations on the MySql database

PHP REST API using slim framework and CRUD operations šŸ– Hi there, this is a simple REST API built using the Slim framework. And this is for the folks

A Slim PHP MVC framework built just for fun!

Aura Framework A Slim PHP MVC framework built just for fun! en: Note: This repository only contains the core code of the Aura framework. If you want t

Slim Framework skeleton application with MVC Schema

Slim Framework skeleton application with MVC Schema

A curated list of awesome tutorials and other resources for the Slim micro framework

Awesome Slim A curated list of awesome tutorials and other resources for the Slim micro framework Table of Contents Essentials Tutorials Packages and

Slim Framework 3 Skeleton Application + PagSeguro Lib

Slim Framework 3 Skeleton Application + PagSeguro Lib AplicaĆ§Ć£o simples para geraĆ§Ć£o do Token para pagamentos no PagSeguro (mĆ©todo transparente) e env

My personal blog developed on the Slim Framework

nesbot.com I am making the source code of my personal site available publicly in case it helps anybody. It's developed using the Slim Framework. I am

Plates Template Integration for Slim micro framework 3

Plates Template Integration for Slim micro framework 3 Render your Slim 3 application views using Plates template engine. Install Via Composer $ compo

Strict PSR-7 implementation used by the Slim Framework

Strict PSR-7 implementation used by the Slim Framework, but you may use it separately with any framework compatible with the PSR-7 standard.

Slim Framework custom views

Slim Views This repository contains custom View classes for the template frameworks listed below. You can use any of these custom View classes by eith

Owner
Alexandre Bouvier
Alexandre Bouvier
Juliangut Slim Framework Doctrine handler middleware

Juliangut Slim Framework Doctrine handler middleware Doctrine handler middleware for Slim Framework. Slim3 version Doctrine integration service for Sl

JuliƔn GutiƩrrez 6 Mar 23, 2021
This Slim Framework middleware will compile LESS CSS files on-the-fly using the Assetic library

This Slim Framework middleware will compile LESS CSS files on-the-fly using the Assetic library. It supports minification and caching, also via Asseti

Gerard Sychay 22 Mar 31, 2020
Redis cache middleware for Slim framework

RedisCache Redis cache middleware for Slim framework. Installation composer require abouvier/slim-redis-cache Usage Cache every successful HTTP respo

Alexandre Bouvier 16 Sep 20, 2021
Slim Framework HTTP cache middleware and service provider

Slim Framework HTTP Cache This repository contains a Slim Framework HTTP cache middleware and service provider. Install Via Composer $ composer requir

Slim Framework 107 Dec 15, 2022
CORS Middleware for PHP Slim Framework

CorsSlim Cross-origin resource sharing (CORS) Middleware for PHP Slim Framework. Usage Composer Autoloader Install with Composer Update your composer.

Palani Kumanan 92 Nov 30, 2021
PHP slim framework middleware to minify HTML output

slim-minify Slim middleware to minify HTML output generated by the slim PHP framework. It removes whitespaces, empty lines, tabs beetween html-tags an

Christian Klisch 35 Oct 31, 2021
Slim Framework CSRF protection middleware

Slim Framework CSRF Protection This repository contains a Slim Framework CSRF protection PSR-15 middleware. CSRF protection applies to all unsafe HTTP

Slim Framework 302 Dec 11, 2022
Laravel 8 Project Restrict User Access From IP Addresses. prevent other ip address that want to access over secure api or urls.

block-ip-address-laravel Laravel 8 Project Restrict User Access From IP Addresses. prevent other ip address that want to access over secure api or url

Hasmukh Dharajiya 2 Mar 24, 2022
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

Slim Framework 11.5k Jan 4, 2023
Slim Framework - Prerequisite Checker

Slim Framework - Server Configuration Checker Upload the file check.php to your webserver Browse to the file: https://example.com/check.php Check the

Daniel Opitz 6 Aug 30, 2022