PHP code example of exceed / exauth
1. Go to this page and download the library: Download exceed/exauth library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
exceed / exauth example snippets
$psr4 = [
'exAuth' => APPPATH . 'ThirdParty/exauth/src',
];
service('auth')->routes($routes);
public array $validFields = ['email', 'username'];
public bool $useEmailForLogin = true;
public bool $useUsernameForLogin = true;
// app/Config/Routes.php
service('auth')->routes($routes);
ex_auth()
ex_logged_in()
ex_current_user()
ex_user_id()
ex_logout()
'session' => Session-based auth (redirect to /login if not logged in)
'tokens' => Bearer token auth (returns 401 JSON on failure)
'hmac' => HMAC signature auth (returns 401 JSON on failure)
'jwt' => JWT Bearer token auth (returns 401 JSON on failure)
'chain' => Tries session, tokens, jwt, hmac in sequence
'group' => Checks group membership
'permission' => Checks permissions
public $filters = [
'login' => ['before' => ['account/*']],
];
public $globals = [
'before' => [
'honeypot',
'login',
...
],
];
$routes->get('admin/users', 'UserController::index', ['filter' => 'permission:users.manage']);
$routes->get('admin/users', 'UserController::index', ['filter' => 'group:admin,superadmin']);
$routes->group('admin', ['filter' => 'group:admin,superadmin'], function($routes) {
...
});
$routes->get('api/profile', 'Profile::index', ['filter' => 'chain:session,tokens,jwt']);
shell
php spark exauth:setup
bash
php spark exauth:user addgroup -n johndoe -g admin