Skip to content

Repository files navigation

jasny-banner

Jasny Auth

PHPScrutinizer Code QualityCode CoveragePackagist Stable VersionPackagist License

Authentication, authorization and access control for Slim Framework and other PHP micro-frameworks.

Features


Installation

Install using composer

composer require jasny/auth

Usage

Auth is a composition class. It takes an authz, storage, and optionally a confirmation service.

useJasny\Auth\Auth;
useJasny\Auth\Authz\Levels;
$levels = newLevels(['user' => 1, 'moderator' => 10, 'admin' => 100]);
$auth = newAuth($levels, newAuthStorage());
session_start();
$auth->initialize();
// Later...if (!$auth->is('admin')) {
http_response_code(403);
echo"Access denied";
exit();
}

The Auth service isn't usable until it's initialized. This should be done after the session is started.

session_start();
$auth->initialize();

Documentation

About

Authentication, authorization and access control for Slim and other micro-frameworks

Topics

Resources

Stars

113 stars

Watchers

11 watching

Forks

Releases

Packages

Used by

Contributors

Languages