Download the PHP package deisss/slim-auth without Composer
On this page you can find all versions of the php package deisss/slim-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deisss/slim-auth
More information about deisss/slim-auth
Files in deisss/slim-auth
Package slim-auth
Short Description An abstract HTTP Basic Auth middleware for PHP Slim framework, offering easy custom database schema, and url escaping possibilities
License MIT
Homepage https://github.com/Deisss/php-slim-auth
Informations about the package slim-auth
php-slim-auth
Simple, and yet powerfull middleware authentification for PHP Slim framework.
Principle
We try threw this system to keep it as simple as possible. So we provide an authentification in two -extremely easy- parts:
- We take care of authentification process, using HTTP Basic Auth,
- You extend this abstract class, to add your login/business logic to it.
Finally, you plug your extended class to Slim, and we are done.
Installation
The system is using composer as main delivery system, using :
Recompile composer threw command line
Usage
A login logic can be quite different from every system (like stateless, session based, facebook based), we decide it was necessary to provide a system where you can add your logic to it. An abstract authentification class was the best way to achieve this, and keep everything simple. So, as it's abstract, you need to create your own concrete class:
Now this class is created (we consider the file name as , we can use it:
We show here a full example where we skip the auth for path (as you see skip handle same variable system as Slim). And for path, we get back the user auth result from (so here, ). You can of course return object instead of boolean , to get full user!
Furthermore
We didn't provide any ACL system, but regarding the Slim behavior, it can get quite simple to, using route middleware (Note: we consider same example as above):
As you see, the ACL is also handled in a quick, and easy way, this is simply because a simple fact: the 'global' middleware, is perform BEFORE the 'route' middleware, allowing us to already know everything about user, inside the 'route' middleware one.
License
Simple MIT License, hope you enjoy!