PHP code example of judasprabin / auth-manager

1. Go to this page and download the library: Download judasprabin/auth-manager 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/ */

    

judasprabin / auth-manager example snippets


$app->register(Carsguide\Auth\Providers\AuthManagerServiceProvider::class);

Carsguide\Auth\Providers\AuthManagerServiceProvider::class,

$app->routeMiddleware([
    'auth' => Carsguide\Auth\Middlewares\Auth0Middleware::class,
]);

protected $routeMiddleware = [
    'auth' => \Carsguide\Auth\Middlewares\Auth0Middleware::class,
];

use Carsguide\Auth\AuthManager;
use GuzzleHttp\Client;

$auth = new AuthManager(new Client());
$auth = $auth->setAudience('foobar');
$auth->getToken();

use Carsguide\Auth\Facades\AuthManager;

AuthManager::setAudience('foobar')->getToken();

 AuthManager::setAudience('foobar')
    // By default, JWT will cache for 50 minutes
    // If you need to override the default length, 
    // pass minutes in cache(120) method.
    ->cache() // or ->cache($minutes = 120)
    ->getToken();

$this->middleware('auth:listings:read');

$router->get('admin/profile', ['middleware' => 'auth:listings:read', function () {
    //
}]);